refactor: place all presentation code in a presentation folder
Some features didn't have this folder.
Bug: twpowertools:226
Change-Id: Ic9803e7ee66a15c6c9e083509e059e453a26ed0f
diff --git a/src/features/ccDarkTheme/presentation/nodeWatcherHandlers/unifiedProfilesIframe.handler.ts b/src/features/ccDarkTheme/presentation/nodeWatcherHandlers/unifiedProfilesIframe.handler.ts
new file mode 100644
index 0000000..13b6cc9
--- /dev/null
+++ b/src/features/ccDarkTheme/presentation/nodeWatcherHandlers/unifiedProfilesIframe.handler.ts
@@ -0,0 +1,27 @@
+import CssSelectorNodeWatcherHandler from '../../../../infrastructure/presentation/nodeWatcher/handlers/CssSelectorHandler.adapter';
+import { NodeMutation } from '../../../../presentation/nodeWatcher/NodeWatcherHandler';
+import { OptionsProviderPort } from '../../../../services/options/OptionsProvider';
+import { isDarkThemeOn } from '../../core/logic/darkTheme';
+import { unifiedProfilesFix } from '../../core/logic/unifiedProfiles';
+
+/**
+ * Redirect unified profile iframe to dark version if applicable
+ */
+export default class CCDarkThemeUnifiedProfilesIframeHandler extends CssSelectorNodeWatcherHandler {
+ cssSelector = 'iframe';
+
+ constructor(private optionsProvider: OptionsProviderPort) {
+ super();
+ }
+
+ async onMutatedNode(mutation: NodeMutation) {
+ const optionsValues = await this.optionsProvider.getOptionsValues();
+
+ if (
+ isDarkThemeOn(optionsValues) &&
+ unifiedProfilesFix.checkIframe(mutation.node)
+ ) {
+ unifiedProfilesFix.fixIframe(mutation.node);
+ }
+ }
+}