Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/datasource/youtube/YouTubeMusicDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4692,6 +4692,12 @@ export class YouTubeMusicDataSource extends DataSource {
private async fetchSyncedLyrics(track: Track): Promise<Lyrics> {
logInternalInfo("YouTubeMusicDataSource.getLyrics start", { trackId: track.id });

// Queue rows carry no duration, so an auto-advanced track used to skip both LRCLIB sources (#153).
if (!track.durationSec && track.source === "youtube") {
const durationSec = (await this.getTrack(track.id).catch(() => null))?.durationSec;
if (durationSec) track = { ...track, durationSec };
}

const runners: Record<string, () => Promise<Lyrics | null>> = {
"lrclib-exact": () => this.fetchLrcLibExactLyrics(track),
betterlyrics: () => this.fetchBetterLyrics(track),
Expand Down
9 changes: 9 additions & 0 deletions src/internal/lyricsSourcePreference.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useSyncExternalStore } from "react";
import { getAppSetting, setAppSetting } from "./appSettings";

/**
* Which lyric source the listener wants tried first.
Expand Down Expand Up @@ -38,6 +39,14 @@ export function setPreferredLyricsSourceId(id: string): void {
// Quota or a locked profile: the choice still applies for this session.
}
window.dispatchEvent(new Event(CHANGE_EVENT));
void setAppSetting(STORAGE_KEY, id);
}

/** Webview storage alone lost this on every restart for some Windows users (#153). */
export async function hydratePreferredLyricsSourceId(): Promise<void> {
const stored = await getAppSetting<unknown>(STORAGE_KEY);
// No durable copy yet: backfill it from local storage.
setPreferredLyricsSourceId(typeof stored === "string" ? stored : getPreferredLyricsSourceId());
}

function subscribe(listener: () => void): () => void {
Expand Down
2 changes: 2 additions & 0 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { DiscordRpcService } from "./player/DiscordRPC";
import { hydratePlaybackSettings } from "./player/playbackSettings";
import { hydratePlayHistory } from "./player/playHistory";
import { hydrateSessionRestoreSetting } from "./ui/settings/sessionRestore";
import { hydratePreferredLyricsSourceId } from "./internal/lyricsSourcePreference";
import { hydrateToolbarItemSettings } from "./ui/settings/toolbarItems";
import { hydrateHomeSectionSettings } from "./ui/settings/homeSections";
import { applyRenderEffects, hydrateRenderEffects } from "./ui/settings/renderEffects";
Expand Down Expand Up @@ -86,6 +87,7 @@ void Promise.all([
hydrateHomeSectionSettings(),
hydratePlaybackSettings(),
hydratePlayHistory(),
hydratePreferredLyricsSourceId(),
// Read synchronously from local storage at boot, so this only backfills a machine whose
// local storage was cleared — it takes effect from the next launch.
hydrateSessionRestoreSetting(),
Expand Down
Loading