From 0d2a14d22971f4d911c911396fb6641bfda178a9 Mon Sep 17 00:00:00 2001 From: Crxaw <48805031+sitescript@users.noreply.github.com> Date: Fri, 21 Mar 2025 16:32:56 +0000 Subject: [PATCH] Removes spamming Notifications FULLY / Moved to console logging --- .../spotifyLyrics/providers/store.ts | 42 ++++++++++++++++--- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/src/equicordplugins/spotifyLyrics/providers/store.ts b/src/equicordplugins/spotifyLyrics/providers/store.ts index 6cd9f155..574eedb0 100644 --- a/src/equicordplugins/spotifyLyrics/providers/store.ts +++ b/src/equicordplugins/spotifyLyrics/providers/store.ts @@ -102,19 +102,38 @@ export const SpotifyLrcStore = proxyLazyWebpack(() => { store.emitChange(); return; } - + // stops spamming noftications for translation when there is no lyrics x1 if (provider === Provider.Translated || provider === Provider.Romanized) { if (!currentInfo?.useLyric || !currentInfo.lyricsVersions[currentInfo.useLyric]) { + console.log("Failed to Translate"); + const now = Date.now(); + if (!window.__lastTranslateFailure) { + window.__lastTranslateFailure = now; + } else if (now - window.__lastTranslateFailure < 120000) { // 2 minutes + window.__lastTranslateFailure = null; + return null; + } else { + window.__lastTranslateFailure = now; + } return null; } const fetcher = provider === Provider.Translated ? translateLyrics : romanizeLyrics; const fetchResult = await fetcher(currentInfo.lyricsVersions[currentInfo.useLyric]); - + // stops spamming noftications for when there is no lyrics / cannot be translated x2 if (!fetchResult) { - showNotif("Lyrics fetch failed", `Failed to fetch ${provider === Provider.Translated ? "translation" : "romanization"}`); - return; + console.log("Lyrics fetch failed", `Failed to fetch ${provider === Provider.Translated ? "translation" : "romanization"}`); + const now = Date.now(); + if (!window.__lastTranslateFailure) { + window.__lastTranslateFailure = now; + } else if (now - window.__lastTranslateFailure < 120000) { // 2 minutes + window.__lastTranslateFailure = null; + return null; + } else { + window.__lastTranslateFailure = now; + } + return null; } store.lyricsInfo = { @@ -133,9 +152,19 @@ export const SpotifyLrcStore = proxyLazyWebpack(() => { } const newLyricsInfo = await lyricFetchers[e.provider](store.track!); + // stops spamming noftications for when there is no lyrics / cannot be translated x3 if (!newLyricsInfo) { - showNotif("Lyrics fetch failed", `Failed to fetch ${e.provider} lyrics`); - return; + console.log("Lyrics fetch failed", `Failed to fetch ${e.provider} lyrics`); + const now = Date.now(); + if (!window.__lastLyricsFetchFailure) { + window.__lastLyricsFetchFailure = now; + } else if (now - window.__lastLyricsFetchFailure < 120000) { // 2 minutes + window.__lastLyricsFetchFailure = null; + return null; + } else { + window.__lastLyricsFetchFailure = now; + } + return null; } store.lyricsInfo = newLyricsInfo; @@ -147,3 +176,4 @@ export const SpotifyLrcStore = proxyLazyWebpack(() => { }); return store; }); +