fix react-hooks/exhaustive-deps warnings
This commit is contained in:
+13
-14
@@ -332,18 +332,22 @@ export default function PlayerPage() {
|
||||
|
||||
/* Resume prompt: show on first mount when there's a saved position
|
||||
* past the threshold AND the user wants the prompt AND the URL didn't
|
||||
* already specify ?resume=true (queue navigation path). */
|
||||
* already specify ?resume=true (queue navigation path).
|
||||
* Intentionally scoped to item?.Id only - we only want to evaluate
|
||||
* the resume condition once per item, not re-trigger when item data
|
||||
* refreshes or prefs change mid-playback. */
|
||||
const resumePromptShownRef = useRef<string | null>(null)
|
||||
useEffect(() => {
|
||||
if (!item) return
|
||||
if (!item || resumePromptShownRef.current === item.Id) return
|
||||
const pos = Number(item.UserData?.PlaybackPositionTicks ?? 0)
|
||||
const thresholdSec = usePreferencesStore.getState().resumeThresholdSec ?? 5
|
||||
const threshold = thresholdSec * 10_000_000
|
||||
const fromQueue = searchParams.get('resume') === 'true'
|
||||
if (showResumePromptPref && !fromQueue && pos > threshold) {
|
||||
setResumePromptOpen(true)
|
||||
resumePromptShownRef.current = item.Id
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [item?.Id])
|
||||
}, [item?.Id, searchParams, showResumePromptPref])
|
||||
|
||||
/* Auto-rewatch counter: when an already-played item starts playing
|
||||
* again, record the rewatch. We trip it at most once per item-mount
|
||||
@@ -358,8 +362,7 @@ export default function PlayerPage() {
|
||||
if (rewatchedItemIdRef.current === item.Id) return
|
||||
rewatchedItemIdRef.current = item.Id
|
||||
usePersonalData.getState().incrementRewatch(item.Id)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [item?.Id])
|
||||
}, [item])
|
||||
|
||||
/* Auto-recap trigger: decide once per item. Recap card waits for the
|
||||
* resume prompt (if any) to resolve before appearing. */
|
||||
@@ -376,8 +379,7 @@ export default function PlayerPage() {
|
||||
} else {
|
||||
setRecapPending(false)
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [item?.Id, recapTrigger.shouldShow])
|
||||
}, [item?.Id, recapTrigger.shouldShow, showRecapCardPref, item])
|
||||
useEffect(() => {
|
||||
if (recapPending && !resumePromptOpen) {
|
||||
setRecapCardOpen(true)
|
||||
@@ -429,8 +431,7 @@ export default function PlayerPage() {
|
||||
qc.removeQueries({ queryKey: ['jellyfin', 'episodes', evictId], exact: false })
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [id])
|
||||
}, [id, qc])
|
||||
|
||||
/* Aggressive teardown on player unmount.
|
||||
*
|
||||
@@ -638,8 +639,7 @@ export default function PlayerPage() {
|
||||
p.currentTime = target
|
||||
if (seriesId) recordSkippedSeconds(seriesId, 'credits', target - from)
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [currentMarker?.type, currentMarker?.startSec, skipIntros, skipCredits])
|
||||
}, [currentMarker?.type, currentMarker?.startSec, skipIntros, skipCredits, duration, seriesId])
|
||||
|
||||
/* Imperatively switch the active subtitle track. We use 'hidden' rather
|
||||
* than 'showing' so the browser doesn't paint its own caption UI over our
|
||||
@@ -720,8 +720,7 @@ export default function PlayerPage() {
|
||||
// default: prefer a language match, then default-flagged, then off
|
||||
const match = pickSubtitle(subs, subtitleLanguage)
|
||||
setSubtitleIndex(match?.Index ?? null)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [id, mediaSourceId, subtitleStreams.length, subtitleMode, subtitleLanguage])
|
||||
}, [id, mediaSourceId, subtitleStreams.length, subtitleMode, subtitleLanguage, item])
|
||||
|
||||
/* ── Playback reporting ──────────────────────────────────── */
|
||||
const playSessionId = playbackInfo?.PlaySessionId || undefined
|
||||
|
||||
Reference in New Issue
Block a user