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();
|
||||
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;
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue