Skip to content

Commit

Permalink
Fix for showTags #14
Browse files Browse the repository at this point in the history
  • Loading branch information
Inrixia committed Dec 20, 2023
1 parent 4546fdc commit 80e3143
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 50 deletions.
67 changes: 33 additions & 34 deletions plugins/TidalTags/src/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,43 +34,42 @@ export const Settings = () => {
updateTrackLists();
};
return html`<div class="settings-section">
<h3 class="settings-header">Display Tags</h3>
<p class="settings-explainer">Display Quality Tags.</p>
<label class="switch">
<input type="checkbox" id="showAllQualities" onChange=${onChange("showAllQualities")} />
<span class="slider" />
</label>
<h3 class="settings-header">Display Tags</h3>
<p class="settings-explainer">Display Quality Tags.</p>
<label class="switch">
<input type="checkbox" id="showTags" onChange=${onChange("showTags")} />
<span class="slider" />
</label>
<h3 class="settings-header">Display all Qualities</h3>
<p class="settings-explainer">Display MQA if HiRes is avalible.</p>
<label class="switch">
<input type="checkbox" id="showTags" onChange=${onChange("showTags")} />
<span class="slider" />
</label>
<h3 class="settings-header">Display all Qualities</h3>
<p class="settings-explainer">Display MQA if HiRes is avalible.</p>
<label class="switch">
<input type="checkbox" id="showAllQualities" onChange=${onChange("showAllQualities")} />
<span class="slider" />
</label>
<br class="settings-spacer" />
<h3 class="settings-header">Display Atmos Quality</h3>
<p class="settings-explainer">Display the Atmos Quality tags.</p>
<label class="switch">
<input type="checkbox" id="showAtmosQuality" onChange=${onChange("showAtmosQuality")} />
<span class="slider" />
</label>
<br class="settings-spacer" />
<h3 class="settings-header">Display Atmos Quality</h3>
<p class="settings-explainer">Display the Atmos Quality tags.</p>
<label class="switch">
<input type="checkbox" id="showAtmosQuality" onChange=${onChange("showAtmosQuality")} />
<span class="slider" />
</label>
<br class="settings-spacer" />
<h3 class="settings-header">Show FLAC Info</h3>
<p class="settings-explainer">Show Sample Rate/Bit Depth</p>
<label class="switch">
<input type="checkbox" id="showFLACInfo" onChange=${onChange("showFLACInfo")} />
<span class="slider" />
</label>
<br class="settings-spacer" />
<h3 class="settings-header">Show FLAC Info</h3>
<p class="settings-explainer">Show Sample Rate/Bit Depth</p>
<label class="switch">
<input type="checkbox" id="showFLACInfo" onChange=${onChange("showFLACInfo")} />
<span class="slider" />
</label>
<br class="settings-spacer" />
<h3 class="settings-header">Show FLAC Info Border</h3>
<p class="settings-explainer">Show a border around the FLAC Info</p>
<label class="switch">
<input type="checkbox" id="showFLACInfoBorder" onChange=${onChange("showFLACInfoBorder")} />
<span class="slider" />
</label>
</div>
<br class="settings-spacer" />
<h3 class="settings-header">Show FLAC Info Border</h3>
<p class="settings-explainer">Show a border around the FLAC Info</p>
<label class="switch">
<input type="checkbox" id="showFLACInfoBorder" onChange=${onChange("showFLACInfoBorder")} />
<span class="slider" />
</label>
</div>`;
};
31 changes: 15 additions & 16 deletions plugins/TidalTags/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};

0 comments on commit 80e3143

Please sign in to comment.