Skip to content
Merged
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
12 changes: 8 additions & 4 deletions desktop/src/renderer/components/LyricsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
const animated = mapped.synced && !plain;
const stampRef = useRef(stamp);
stampRef.current = stamp;
const mappedRef = useRef(mapped);
mappedRef.current = mapped;

// Create/destroy the DOM player for synced tiers.
useEffect(() => {
Expand All @@ -51,18 +53,20 @@
p.setWordFadeWidth(0.5);
host.current.replaceChildren(p.getElement());
player.current = p;
// AMLL re-dispatches DOM clicks on a line as "line-click" (not "click").
const onClick = (e: Event) => {
const ev = e as LyricLineMouseEvent;
const line = mapped.lines[ev.lineIndex];
if (line) bridge().dispatch({ type: "seekTo", data: { position_ms: Math.max(0, line.startTime - mapped.offsetMs) } });
const m = mappedRef.current;
const line = m.lines[ev.lineIndex];
if (line) bridge().dispatch({ type: "seekTo", data: { position_ms: Math.max(0, line.startTime - m.offsetMs) } });
};
p.addEventListener("click", onClick);
p.addEventListener("line-click", onClick);
return () => {
p.removeEventListener("click", onClick);
p.removeEventListener("line-click", onClick);
p.dispose();
player.current = undefined;
};
}, [animated, variant]);

Check warning on line 69 in desktop/src/renderer/components/LyricsView.tsx

View workflow job for this annotation

GitHub Actions / Desktop

React Hook useEffect has a missing dependency: 'batterySaver'. Either include it or remove the dependency array

useEffect(() => {
const p = player.current;
Expand All @@ -71,7 +75,7 @@
p.setLyricLines(mapped.lines as never, extrapolate(stampRef.current, Date.now(), clockOffset, duration));
p.setCurrentTime(extrapolate(stampRef.current, Date.now(), clockOffset, duration), true);
p.update(0);
}, [mapped, batterySaver, animated]);

Check warning on line 78 in desktop/src/renderer/components/LyricsView.tsx

View workflow job for this annotation

GitHub Actions / Desktop

React Hook useEffect has missing dependencies: 'clockOffset', 'duration', and 'variant'. Either include them or remove the dependency array

// Seek detection: a jump in the stamp means isSeek=true so AMLL relayouts.
const lastStamp = useRef(stamp);
Expand Down
Loading