Removes spamming Notifications FULLY / Moved to console logging (#191)

This commit is contained in:
Crxaw 2025-03-21 16:40:07 +00:00 committed by GitHub
parent a3e74c44df
commit 45585dd5a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -102,19 +102,38 @@ export const SpotifyLrcStore = proxyLazyWebpack(() => {
store.emitChange(); store.emitChange();
return; return;
} }
// stops spamming noftications for translation when there is no lyrics x1
if (provider === Provider.Translated || provider === Provider.Romanized) { if (provider === Provider.Translated || provider === Provider.Romanized) {
if (!currentInfo?.useLyric || !currentInfo.lyricsVersions[currentInfo.useLyric]) { 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; return null;
} }
const fetcher = provider === Provider.Translated ? translateLyrics : romanizeLyrics; const fetcher = provider === Provider.Translated ? translateLyrics : romanizeLyrics;
const fetchResult = await fetcher(currentInfo.lyricsVersions[currentInfo.useLyric]); const fetchResult = await fetcher(currentInfo.lyricsVersions[currentInfo.useLyric]);
// stops spamming noftications for when there is no lyrics / cannot be translated x2
if (!fetchResult) { if (!fetchResult) {
showNotif("Lyrics fetch failed", `Failed to fetch ${provider === Provider.Translated ? "translation" : "romanization"}`); console.log("Lyrics fetch failed", `Failed to fetch ${provider === Provider.Translated ? "translation" : "romanization"}`);
return; 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 = { store.lyricsInfo = {
@ -133,9 +152,19 @@ export const SpotifyLrcStore = proxyLazyWebpack(() => {
} }
const newLyricsInfo = await lyricFetchers[e.provider](store.track!); const newLyricsInfo = await lyricFetchers[e.provider](store.track!);
// stops spamming noftications for when there is no lyrics / cannot be translated x3
if (!newLyricsInfo) { if (!newLyricsInfo) {
showNotif("Lyrics fetch failed", `Failed to fetch ${e.provider} lyrics`); console.log("Lyrics fetch failed", `Failed to fetch ${e.provider} lyrics`);
return; 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; store.lyricsInfo = newLyricsInfo;
@ -147,3 +176,4 @@ export const SpotifyLrcStore = proxyLazyWebpack(() => {
}); });
return store; return store;
}); });