refactor(infinite-scroll): migrate to the new DI architecture
Bug: twpowertools:226
Change-Id: I5f4156204327cc66e976821134cef667d57f7233
diff --git a/src/features/infiniteScroll/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBar.handler.ts b/src/features/infiniteScroll/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBar.handler.ts
index 5c2d308..d1068e3 100644
--- a/src/features/infiniteScroll/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBar.handler.ts
+++ b/src/features/infiniteScroll/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBar.handler.ts
@@ -1,10 +1,14 @@
import { NodeMutation } from '../../../presentation/nodeWatcher/NodeWatcherHandler';
-import CssSelectorNodeWatcherScriptHandler from '../../../common/architecture/scripts/nodeWatcher/handlers/CssSelectorNodeWatcherScriptHandler';
-import { InfiniteScrollNodeWatcherOptions } from '../scripts/ccInfiniteScroll.script';
+import CCInfiniteScroll from '../core/ccInfiniteScroll';
+import CssSelectorNodeWatcherHandler from '../../../infrastructure/presentation/nodeWatcher/handlers/CssSelectorHandler.adapter';
-export default class CCInfiniteScrollLoadMoreBarHandler extends CssSelectorNodeWatcherScriptHandler<InfiniteScrollNodeWatcherOptions> {
+export default class CCInfiniteScrollLoadMoreBarHandler extends CssSelectorNodeWatcherHandler {
cssSelector = '.load-more-bar';
+ constructor(private ccInfiniteScroll: CCInfiniteScroll) {
+ super();
+ }
+
onMutatedNode({ node }: NodeMutation) {
if (!(node instanceof Element)) {
console.error(
@@ -13,6 +17,6 @@
);
return;
}
- this.options.ccInfiniteScroll.observeLoadMoreBar(node);
+ this.ccInfiniteScroll.observeLoadMoreBar(node);
}
}
diff --git a/src/features/infiniteScroll/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBtn.handler.ts b/src/features/infiniteScroll/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBtn.handler.ts
index 1ab8644..0dd8db6 100644
--- a/src/features/infiniteScroll/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBtn.handler.ts
+++ b/src/features/infiniteScroll/nodeWatcherHandlers/ccInfiniteScrollLoadMoreBtn.handler.ts
@@ -1,11 +1,15 @@
import { NodeMutation } from '../../../presentation/nodeWatcher/NodeWatcherHandler';
-import CssSelectorNodeWatcherScriptHandler from '../../../common/architecture/scripts/nodeWatcher/handlers/CssSelectorNodeWatcherScriptHandler';
-import { InfiniteScrollNodeWatcherOptions } from '../scripts/ccInfiniteScroll.script';
+import CssSelectorNodeWatcherHandler from '../../../infrastructure/presentation/nodeWatcher/handlers/CssSelectorHandler.adapter';
+import CCInfiniteScroll from '../core/ccInfiniteScroll';
-export default class CCInfiniteScrollLoadMoreBtnHandler extends CssSelectorNodeWatcherScriptHandler<InfiniteScrollNodeWatcherOptions> {
+export default class CCInfiniteScrollLoadMoreBtnHandler extends CssSelectorNodeWatcherHandler {
cssSelector =
'.scTailwindThreadMorebuttonbutton, .scTailwindThreadMessagegapbutton';
+ constructor(private ccInfiniteScroll: CCInfiniteScroll) {
+ super();
+ }
+
onMutatedNode({ node }: NodeMutation) {
if (!(node instanceof Element)) {
console.error(
@@ -14,6 +18,6 @@
);
return;
}
- this.options.ccInfiniteScroll.observeLoadMoreInteropBtn(node);
+ this.ccInfiniteScroll.observeLoadMoreInteropBtn(node);
}
}
diff --git a/src/features/infiniteScroll/nodeWatcherHandlers/ccInfiniteScrollSetUp.handler.ts b/src/features/infiniteScroll/nodeWatcherHandlers/ccInfiniteScrollSetUp.handler.ts
index b36e0b9..0d77cf7 100644
--- a/src/features/infiniteScroll/nodeWatcherHandlers/ccInfiniteScrollSetUp.handler.ts
+++ b/src/features/infiniteScroll/nodeWatcherHandlers/ccInfiniteScrollSetUp.handler.ts
@@ -1,16 +1,17 @@
import { NodeMutation } from '../../../presentation/nodeWatcher/NodeWatcherHandler';
-import CssSelectorNodeWatcherScriptHandler from '../../../common/architecture/scripts/nodeWatcher/handlers/CssSelectorNodeWatcherScriptHandler';
-import { InfiniteScrollNodeWatcherOptions } from '../scripts/ccInfiniteScroll.script';
+import CssSelectorNodeWatcherHandler from '../../../infrastructure/presentation/nodeWatcher/handlers/CssSelectorHandler.adapter';
+import CCInfiniteScroll from '../core/ccInfiniteScroll';
-export default class CCInfiniteScrollSetUpHandler extends CssSelectorNodeWatcherScriptHandler<InfiniteScrollNodeWatcherOptions> {
+export default class CCInfiniteScrollSetUpHandler extends CssSelectorNodeWatcherHandler {
cssSelector = 'ec-app, .scrollable-content';
+ constructor(private ccInfiniteScroll: CCInfiniteScroll) {
+ super();
+ }
+
onMutatedNode({ node }: NodeMutation) {
if (!(node instanceof Element)) return;
const isScrollableContent = node.classList.contains('scrollable-content');
- this.options.ccInfiniteScroll.setUpIntersectionObserver(
- node,
- isScrollableContent,
- );
+ this.ccInfiniteScroll.setUpIntersectionObserver(node, isScrollableContent);
}
}