mirror of
https://github.com/Equicord/Equicord.git
synced 2025-04-01 13:11:57 -04:00
Removes spamming Notifications FULLY / Moved to console logging (#191)
This commit is contained in:
parent
a3e74c44df
commit
45585dd5a7
1 changed files with 36 additions and 6 deletions
|
@ -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;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue