refactor: migrate autorefresh feature to the new architecture
Bug: twpowertools:176
Change-Id: If000d8617e9a4d66bdc7f91c1037867a4cb9fbf2
diff --git a/src/features/autoRefresh/nodeWatcherHandlers/threadListHide.handler.ts b/src/features/autoRefresh/nodeWatcherHandlers/threadListHide.handler.ts
new file mode 100644
index 0000000..4b1082d
--- /dev/null
+++ b/src/features/autoRefresh/nodeWatcherHandlers/threadListHide.handler.ts
@@ -0,0 +1,18 @@
+import CssSelectorNodeWatcherScriptHandler from '../../../common/architecture/scripts/nodeWatcher/handlers/CssSelectorNodeWatcherScriptHandler';
+import { NodeMutation, NodeMutationType } from '../../../common/nodeWatcher/NodeWatcherHandler';
+import { AutoRefreshNodeWatcherDependencies } from '../scripts/nodeWatcher.script';
+
+/**
+ * Removes the snackbar when exiting thread list view.
+ */
+export default class AutoRefreshThreadListHideHandler extends CssSelectorNodeWatcherScriptHandler<AutoRefreshNodeWatcherDependencies> {
+ cssSelector = 'ec-thread-list';
+
+ readonly mutationTypesProcessed: NodeMutationType[] = [
+ NodeMutationType.RemovedNode,
+ ];
+
+ onMutatedNode(_: NodeMutation) {
+ this.options.autoRefresh.hideUpdatePrompt();
+ }
+}
diff --git a/src/features/autoRefresh/nodeWatcherHandlers/threadListSetUp.handler.ts b/src/features/autoRefresh/nodeWatcherHandlers/threadListSetUp.handler.ts
new file mode 100644
index 0000000..554be00
--- /dev/null
+++ b/src/features/autoRefresh/nodeWatcherHandlers/threadListSetUp.handler.ts
@@ -0,0 +1,14 @@
+import CssSelectorNodeWatcherScriptHandler from '../../../common/architecture/scripts/nodeWatcher/handlers/CssSelectorNodeWatcherScriptHandler';
+import { NodeMutation } from '../../../common/nodeWatcher/NodeWatcherHandler';
+import { AutoRefreshNodeWatcherDependencies } from '../scripts/nodeWatcher.script';
+
+/**
+ * Sets up the autorefresh list feature.
+ */
+export default class AutoRefreshThreadListSetUpHandler extends CssSelectorNodeWatcherScriptHandler<AutoRefreshNodeWatcherDependencies> {
+ cssSelector = 'ec-thread-list';
+
+ onMutatedNode(_: NodeMutation) {
+ this.options.autoRefresh.setUp();
+ }
+}