From 80e31433fe92b9ad7487bd35f868415b14b8ad8e Mon Sep 17 00:00:00 2001 From: Inrixia Date: Wed, 20 Dec 2023 14:35:27 +1300 Subject: [PATCH] Fix for showTags #14 --- plugins/TidalTags/src/Settings.ts | 67 +++++++++++++++---------------- plugins/TidalTags/src/index.ts | 31 +++++++------- 2 files changed, 48 insertions(+), 50 deletions(-) diff --git a/plugins/TidalTags/src/Settings.ts b/plugins/TidalTags/src/Settings.ts index 5b6540d..da0df33 100644 --- a/plugins/TidalTags/src/Settings.ts +++ b/plugins/TidalTags/src/Settings.ts @@ -34,43 +34,42 @@ export const Settings = () => { updateTrackLists(); }; return html`
-

Display Tags

-

Display Quality Tags.

- +

Display Tags

+

Display Quality Tags.

+ -

Display all Qualities

-

Display MQA if HiRes is avalible.

- +

Display all Qualities

+

Display MQA if HiRes is avalible.

+ -
-

Display Atmos Quality

-

Display the Atmos Quality tags.

- +
+

Display Atmos Quality

+

Display the Atmos Quality tags.

+ -
-

Show FLAC Info

-

Show Sample Rate/Bit Depth

- +
+

Show FLAC Info

+

Show Sample Rate/Bit Depth

+ -
-

Show FLAC Info Border

-

Show a border around the FLAC Info

- -
+
+

Show FLAC Info Border

+

Show a border around the FLAC Info

+ `; }; diff --git a/plugins/TidalTags/src/index.ts b/plugins/TidalTags/src/index.ts index 1d26c90..28ee599 100644 --- a/plugins/TidalTags/src/index.ts +++ b/plugins/TidalTags/src/index.ts @@ -13,30 +13,29 @@ const unloadIntercept = intercept(["playbackControls/SET_PLAYBACK_STATE", "playb setTimeout(setStreamQualityIndicator); }); -let observer: MutationObserver; -if (storage.showTags) { - const processItems = () => { - observer.disconnect(); - updateTrackLists(); - observer.observe(document.body, { childList: true, subtree: true }); - }; - - let timeoutId: NodeJS.Timeout | null; - const debouncedProcessItems = () => { +const processItems = () => { + observer.disconnect(); + updateTrackLists(); + observer.observe(document.body, { childList: true, subtree: true }); +}; + +let timeoutId: NodeJS.Timeout | null; +const debouncedProcessItems = () => { + if (storage.showTags) { if (timeoutId === null) processItems(); else clearTimeout(timeoutId); timeoutId = setTimeout(() => { processItems(); timeoutId = null; }, 5); - }; + } +}; - observer = new MutationObserver(debouncedProcessItems); - // Start observing the document with the configured parameters - observer.observe(document.body, { childList: true, subtree: true }); -} +const observer = new MutationObserver(debouncedProcessItems); +// Start observing the document with the configured parameters +observer.observe(document.body, { childList: true, subtree: true }); export const onUnload = () => { - if (storage.showTags) observer.disconnect(); + observer.disconnect(); unloadIntercept(); };