Merge pull request #99 from meowarex/dev

Improved Lyric Injection
This commit is contained in:
Meow Meow
2026-04-03 01:15:19 +11:00
committed by GitHub
+29 -14
View File
@@ -367,12 +367,10 @@ const resyncLyrics = async (): Promise<void> => {
}); });
if (res.status === 404) { if (res.status === 404) {
toast("No lyrics found for this track"); toast("No lyrics found for this track");
unlockResync();
return; return;
} }
if (!res.ok) { if (!res.ok) {
toastErr(`Resync failed (${res.status})`); toastErr(`Resync failed (${res.status})`);
unlockResync();
return; return;
} }
const data = (await res.json()) as LyricsApiResponse & { _flush?: string }; const data = (await res.json()) as LyricsApiResponse & { _flush?: string };
@@ -388,12 +386,9 @@ const resyncLyrics = async (): Promise<void> => {
cachedLyricsKey = null; cachedLyricsKey = null;
cachedLyricsData = null; cachedLyricsData = null;
onTrackChange(); onTrackChange();
} else {
unlockResync();
} }
} catch (err) { } catch (err) {
toastErr(`Resync error: ${err instanceof Error ? err.message : String(err)}`); toastErr(`Resync error: ${err instanceof Error ? err.message : String(err)}`);
unlockResync();
} }
}; };
@@ -4019,16 +4014,36 @@ const onTrackChange = async (): Promise<void> => {
watchForRerender(); watchForRerender();
startTickLoop(); startTickLoop();
} else { } else {
watchForRerender(); safeTimeout(unloads, () => {
if (!nativeHasLyrics || settings.stickyLyrics || currentTrackWantsLyricsPanel()) { if (token !== trackChangeToken) return;
safeTimeout(unloads, () => { syncNativeLyricsAvailability();
if (token !== trackChangeToken) return; if (settings.stickyLyrics) {
syncNativeLyricsAvailability(); tryActivateStickyLyricsTab();
if (settings.stickyLyrics) { }
tryActivateStickyLyricsTab(); if (!nativeHasLyrics) {
// Track had no native lyrics but API found them —
// force navigate to lyrics view so the panel mounts
setNowPlayingActiveView("lyrics");
}
}, 0);
let panelRetries = 0;
const waitForPanel = (): void => {
if (token !== trackChangeToken) return;
const panel = getNowPlayingLyricsPanel();
if (panel) {
if (!panel.querySelector(".rl-wbw-container") && lyricsData) {
hideTidalLyrics();
const result = buildWordSpans();
lines = result.lines;
watchForRerender();
startTickLoop();
} }
}, 0); } else if (++panelRetries < 20) {
} safeTimeout(unloads, waitForPanel, 250);
}
};
safeTimeout(unloads, waitForPanel, 250);
} }
} finally { } finally {
if (runId === trackChangeRunSeq) { if (runId === trackChangeRunSeq) {