From b29e9c24ad8e26d3b7908f2f3e8dafbda08967c6 Mon Sep 17 00:00:00 2001 From: ririxi Date: Thu, 31 Aug 2023 13:06:29 +0000 Subject: [PATCH] feat(webnowplaying): use events from wrapper --- Extensions/webnowplaying.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Extensions/webnowplaying.js b/Extensions/webnowplaying.js index 2bb4b0e329..f55cdc2b39 100644 --- a/Extensions/webnowplaying.js +++ b/Extensions/webnowplaying.js @@ -19,7 +19,6 @@ class WNPReduxWebSocket { _ws = null; cache = new Map(); - playerCache = null; reconnectCount = 0; updateInterval = null; communicationRevision = null; @@ -45,12 +44,8 @@ class WNPReduxWebSocket { constructor() { this.init(); - setInterval(() => { - if (objectsAreEqual(Spicetify.Player.data, playerCache)) return; - - playerCache = Spicetify.Player.data; - this.updateSpicetifyInfo(playerCache); - }, 100); + Spicetify.Player.addEventListener("songchange", this.updateSpicetifyInfo.bind(this)); + Spicetify.Player.addEventListener("onplaypause", this.updateSpicetifyInfo.bind(this)); } updateSpicetifyInfo(data) {