refactor(flatten-threads): migrate to the new DI architecture
Bug: twpowertools:176
Change-Id: I7a24fb504ce53697112f11128d2d5249a5a7c7e7
diff --git a/src/contentScripts/communityConsole/main.js b/src/contentScripts/communityConsole/main.js
index 890f3b0..3e914af 100644
--- a/src/contentScripts/communityConsole/main.js
+++ b/src/contentScripts/communityConsole/main.js
@@ -8,11 +8,10 @@
// #!if ['chromium', 'chromium_mv3'].includes(browser_target)
import {applyDragAndDropFixIfEnabled} from './dragAndDropFix.js';
// #!endif
-import {default as FlattenThreads, kMatchingSelectors as kFlattenThreadMatchingSelectors} from './flattenThreads/flattenThreads.js';
import {kRepliesSectionSelector} from './threadToolbar/constants.js';
import ThreadToolbar from './threadToolbar/threadToolbar.js';
-var mutationObserver, options, avatars, threadToolbar, flattenThreads;
+var mutationObserver, options, avatars, threadToolbar;
const watchedNodesSelectors = [
// Scrollable content (used for the intersection observer)
@@ -45,9 +44,6 @@
// Thread page reply section (for the thread page toolbar)
kRepliesSectionSelector,
-
- // Reply payload (for the flatten threads UI)
- ...kFlattenThreadMatchingSelectors,
];
function handleCandidateNode(node) {
@@ -94,31 +90,6 @@
if (threadToolbar.shouldInject(node)) {
threadToolbar.injectIfApplicable(node);
}
-
- // Inject parent reply quote
- if (flattenThreads.shouldInjectQuote(node)) {
- flattenThreads.injectQuoteIfApplicable(node);
- }
-
- // Inject reply button in non-nested view
- if (flattenThreads.shouldInjectReplyBtn(node)) {
- flattenThreads.injectReplyBtnIfApplicable(node);
- }
-
- // Delete additional info in the edit message box
- if (flattenThreads.isAdditionalInfoElement(node)) {
- flattenThreads.deleteAdditionalInfoElementIfApplicable(node);
- }
- }
-}
-
-function handleRemovedNode(mutation, node) {
- if (!('tagName' in node)) return;
-
- // Readd reply button when the Community Console removes it
- if (node.tagName == 'TWPT-FLATTEN-THREAD-REPLY-BUTTON') {
- flattenThreads.injectReplyBtn(
- mutation.target, JSON.parse(node.getAttribute('extraInfo')));
}
}
@@ -128,10 +99,6 @@
mutation.addedNodes.forEach(function(node) {
handleCandidateNode(node);
});
-
- mutation.removedNodes.forEach(function(node) {
- handleRemovedNode(mutation, node);
- });
}
});
}
@@ -147,7 +114,6 @@
// Initialize classes needed by the mutation observer
avatars = new AvatarsHandler();
threadToolbar = new ThreadToolbar();
- flattenThreads = new FlattenThreads();
// Before starting the mutation Observer, check whether we missed any
// mutations by manually checking whether some watched nodes already
@@ -202,8 +168,6 @@
injectStylesheet(chrome.runtime.getURL('css/thread_list_avatars.css'));
// Thread toolbar
injectStylesheet(chrome.runtime.getURL('css/thread_toolbar.css'));
- // Flatten threads
- injectStylesheet(chrome.runtime.getURL('css/flatten_threads.css'));
});
new XHRProxyKillSwitchHandler();