Skip to content

Commit

Permalink
feat(wrapper): remove appchange event from player (#2696)
Browse files Browse the repository at this point in the history
  • Loading branch information
SunsetTechuila authored Dec 5, 2023
1 parent 703d9fc commit 10ada09
Showing 1 changed file with 0 additions and 31 deletions.
31 changes: 0 additions & 31 deletions jsHelper/spicetifyWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2337,37 +2337,6 @@ Spicetify.Playbar = (function () {
Spicetify.Panel.subPanelState(() => clearTimeout(refreshTimeout));
})();

(function waitForHistoryAPI() {
const main = document.querySelector(".main-view-container__scroll-node-child > main");
if (!main || !Spicetify.Platform?.History) {
setTimeout(waitForHistoryAPI, 300);
return;
}

let currentPath;
const observer = new MutationObserver(() => {
const child = main.lastElementChild;
const isPlaceholder = child?.tagName === "DIV" && !child?.children.length;
if (!isPlaceholder) {
const event = new Event("appchange");
event.data = {
path: currentPath,
container: child
};
Spicetify.Player.dispatchEvent(event);
observer.disconnect();
}
});

Spicetify.Platform.History.listen(({ pathname }) => {
if (!Spicetify.Player.eventListeners["appchange"]?.length) {
return;
}
currentPath = pathname;
observer.observe(main, { childList: true });
});
})();

(async function checkForUpdate() {
if (!Spicetify.Config) {
setTimeout(checkForUpdate, 300);
Expand Down

0 comments on commit 10ada09

Please sign in to comment.