refactor(interop-thread-page): migrate to the new DI architecture
Bug: twpowertools:226
Change-Id: Ie2a5e57574a1d986efc6e1c7a64a562d435e956e
diff --git a/src/entryPoints/communityConsole/contentScripts/start.ts b/src/entryPoints/communityConsole/contentScripts/start.ts
index e9be92c..baea65b 100644
--- a/src/entryPoints/communityConsole/contentScripts/start.ts
+++ b/src/entryPoints/communityConsole/contentScripts/start.ts
@@ -1,3 +1,6 @@
+// Run legacy Javascript entry point
+import '../../../contentScripts/communityConsole/start';
+
import DependenciesProviderSingleton, {
AutoRefreshDependency,
} from '../../../common/architecture/dependenciesProvider/DependenciesProvider';
@@ -8,17 +11,15 @@
ScriptRunPhase,
} from '../../../common/architecture/scripts/Script';
import AutoRefreshSetUpScript from '../../../features/autoRefresh/presentation/scripts/setUp.script';
+import CCDarkThemeInjectAutoDarkTheme from '../../../features/ccDarkTheme/scripts/injectAutoDarkTheme.script';
+import CCDarkThemeInjectForcedDarkTheme from '../../../features/ccDarkTheme/scripts/injectForcedDarkTheme.script';
import Features from '../../../features/Features';
+import InteropThreadPageSetupScript from '../../../features/interopThreadPage/presentation/scripts/setup.script';
import ScriptRunner from '../../../infrastructure/presentation/scripts/ScriptRunner';
import ScriptSorterAdapter from '../../../infrastructure/presentation/scripts/ScriptSorter.adapter';
import { SortedScriptsProviderAdapter } from '../../../infrastructure/presentation/scripts/SortedScriptsProvider.adapter';
import StandaloneScripts from '../../../scripts/Scripts';
-// Run legacy Javascript entry point
-import '../../../contentScripts/communityConsole/start';
-import CCDarkThemeInjectAutoDarkTheme from '../../../features/ccDarkTheme/scripts/injectAutoDarkTheme.script';
-import CCDarkThemeInjectForcedDarkTheme from '../../../features/ccDarkTheme/scripts/injectForcedDarkTheme.script';
-
const scriptRunner = createScriptRunner();
scriptRunner.run();
@@ -39,6 +40,7 @@
new AutoRefreshSetUpScript(autoRefresh),
new CCDarkThemeInjectAutoDarkTheme(),
new CCDarkThemeInjectForcedDarkTheme(),
+ new InteropThreadPageSetupScript(),
// Non-DI scripts (legacy, should be migrated to use a DI approach)
...new Features().getScripts(context),
diff --git a/src/features/Features.ts b/src/features/Features.ts
index d0861c5..2f38f34 100644
--- a/src/features/Features.ts
+++ b/src/features/Features.ts
@@ -3,14 +3,12 @@
import ExtraInfoFeature from './extraInfo/extraInfo.feature';
import WorkflowsFeature from './workflows/workflows.feature';
import LoadDraftsFeature from './loadDrafts/loadDrafts.feature';
-import InteropThreadPageFeature from './interopThreadPage/interopThreadPage.feature';
export type ConcreteFeatureClass = { new (): Feature };
export default class Features extends ScriptFilterListProvider {
private features: ConcreteFeatureClass[] = [
ExtraInfoFeature,
- InteropThreadPageFeature,
LoadDraftsFeature,
WorkflowsFeature,
];
diff --git a/src/features/interopThreadPage/interopThreadPage.feature.ts b/src/features/interopThreadPage/interopThreadPage.feature.ts
deleted file mode 100644
index 0d84075..0000000
--- a/src/features/interopThreadPage/interopThreadPage.feature.ts
+++ /dev/null
@@ -1,16 +0,0 @@
-import Feature from '../../common/architecture/features/Feature';
-import { ConcreteScript } from '../../common/architecture/scripts/Script';
-import { OptionCodename } from '../../common/options/optionsPrototype';
-import SetThreadPageInDataStartupScript from './scripts/setThreadPageInDataStartupScript.script';
-
-export default class InteropThreadPageFeature extends Feature {
- public readonly scripts: ConcreteScript[] = [
- SetThreadPageInDataStartupScript,
- ];
-
- readonly codename = 'interopThreadPage';
- readonly relatedOptions: OptionCodename[] = [
- 'interopthreadpage',
- 'interopthreadpage_mode',
- ];
-}
diff --git a/src/features/interopThreadPage/scripts/setThreadPageInDataStartupScript.script.ts b/src/features/interopThreadPage/presentation/scripts/setup.script.ts
similarity index 76%
rename from src/features/interopThreadPage/scripts/setThreadPageInDataStartupScript.script.ts
rename to src/features/interopThreadPage/presentation/scripts/setup.script.ts
index 32c17eb..67c0ce9 100644
--- a/src/features/interopThreadPage/scripts/setThreadPageInDataStartupScript.script.ts
+++ b/src/features/interopThreadPage/presentation/scripts/setup.script.ts
@@ -1,19 +1,15 @@
import DependenciesProviderSingleton, {
OptionsProviderDependency,
StartupDataStorageDependency,
-} from '../../../common/architecture/dependenciesProvider/DependenciesProvider';
-import Script, {
- ScriptEnvironment,
- ScriptPage,
- ScriptRunPhase,
-} from '../../../common/architecture/scripts/Script';
+} from '../../../../common/architecture/dependenciesProvider/DependenciesProvider';
+import Script from '../../../../common/architecture/scripts/Script';
const SMEI_RCE_THREAD_INTEROP = 22;
-export default class SetThreadPageInDataStartupScript extends Script {
- page = ScriptPage.CommunityConsole;
- environment = ScriptEnvironment.ContentScript;
- runPhase = ScriptRunPhase.Start;
+export default class InteropThreadPageSetupScript extends Script {
+ page: never;
+ environment: never;
+ runPhase: never;
async execute() {
const dependenciesProvider = DependenciesProviderSingleton.getInstance();