refactor: migrate autorefresh feature to the new architecture
Bug: twpowertools:176
Change-Id: If000d8617e9a4d66bdc7f91c1037867a4cb9fbf2
diff --git a/src/features/autoRefresh/scripts/nodeWatcher.script.ts b/src/features/autoRefresh/scripts/nodeWatcher.script.ts
new file mode 100644
index 0000000..5308a35
--- /dev/null
+++ b/src/features/autoRefresh/scripts/nodeWatcher.script.ts
@@ -0,0 +1,33 @@
+import DependenciesProviderSingleton, {
+ AutoRefreshDependency,
+} from '../../../common/architecture/dependenciesProvider/DependenciesProvider';
+import {
+ ScriptEnvironment,
+ ScriptPage,
+ ScriptRunPhase,
+} from '../../../common/architecture/scripts/Script';
+import NodeWatcherScript from '../../../common/architecture/scripts/nodeWatcher/NodeWatcherScript';
+import AutoRefresh from '../core/autoRefresh';
+import AutoRefreshThreadListHideHandler from '../nodeWatcherHandlers/threadListHide.handler';
+import AutoRefreshThreadListSetUpHandler from '../nodeWatcherHandlers/threadListSetUp.handler';
+
+export interface AutoRefreshNodeWatcherDependencies {
+ autoRefresh: AutoRefresh;
+}
+
+export default class AutoRefreshNodeWatcherScript extends NodeWatcherScript<AutoRefreshNodeWatcherDependencies> {
+ public page = ScriptPage.CommunityConsole;
+ public environment = ScriptEnvironment.ContentScript;
+ public runPhase = ScriptRunPhase.Main;
+ public handlers = new Map([
+ ['autoRefreshThreadListSetUp', AutoRefreshThreadListSetUpHandler],
+ ['autoRefreshThreadListHide', AutoRefreshThreadListHideHandler],
+ ]);
+
+ protected optionsFactory(): AutoRefreshNodeWatcherDependencies {
+ const dependenciesProvider = DependenciesProviderSingleton.getInstance();
+ return {
+ autoRefresh: dependenciesProvider.getDependency(AutoRefreshDependency),
+ };
+ }
+}
diff --git a/src/features/autoRefresh/scripts/setUp.script.ts b/src/features/autoRefresh/scripts/setUp.script.ts
new file mode 100644
index 0000000..cb5cce6
--- /dev/null
+++ b/src/features/autoRefresh/scripts/setUp.script.ts
@@ -0,0 +1,18 @@
+import {
+ AutoRefreshDependency,
+ Dependency,
+} from '../../../common/architecture/dependenciesProvider/DependenciesProvider';
+import {
+ ScriptEnvironment,
+ ScriptPage,
+ ScriptRunPhase,
+} from '../../../common/architecture/scripts/Script';
+import SetUpDependenciesScript from '../../../common/architecture/scripts/setUpDependencies/SetUpDependenciesScript';
+
+export default class AutoRefreshSetUpScript extends SetUpDependenciesScript {
+ public priority = 100;
+ public page = ScriptPage.CommunityConsole;
+ public environment = ScriptEnvironment.ContentScript;
+ public runPhase = ScriptRunPhase.Start;
+ public dependencies: Dependency[] = [AutoRefreshDependency];
+}
diff --git a/src/features/autoRefresh/scripts/styles.script.ts b/src/features/autoRefresh/scripts/styles.script.ts
new file mode 100644
index 0000000..6e78169
--- /dev/null
+++ b/src/features/autoRefresh/scripts/styles.script.ts
@@ -0,0 +1,16 @@
+import Script, {
+ ScriptEnvironment,
+ ScriptPage,
+ ScriptRunPhase,
+} from '../../../common/architecture/scripts/Script';
+import { injectStylesheet } from '../../../common/contentScriptsUtils';
+
+export default class AutoRefreshStylesScript extends Script {
+ page = ScriptPage.CommunityConsole;
+ environment = ScriptEnvironment.ContentScript;
+ runPhase = ScriptRunPhase.Main;
+
+ execute() {
+ injectStylesheet(chrome.runtime.getURL('css/autorefresh_list.css'));
+ }
+}