fix(playlist): drop stale per-item formats on re-probe
Peer-review of the exact-format-per-item feature: re-clicking "Preview formats" on an already-loaded playlist reset info/playlist but left itemFormats/itemFormatOptions/formatExpanded keyed by position, so a stale exact-format pick could silently reattach to a different video landing at the same index in the new probe result and flow into addPlaylist(). Extracted resetPlaylistItemState() and call it from both clearProbe() and fetchFormats(). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -281,11 +281,11 @@ export function useDownloadBar(): DownloadBarController {
|
|||||||
playlist === null &&
|
playlist === null &&
|
||||||
probeError === null
|
probeError === null
|
||||||
|
|
||||||
function clearProbe(): void {
|
// Per-entry format state is keyed by playlist position, so it must be dropped
|
||||||
setInfo(null)
|
// any time the playlist itself is dropped or re-fetched -- otherwise a stale
|
||||||
setProbeError(null)
|
// exact-format pick from a prior probe can silently reattach to a different
|
||||||
setFormatId('')
|
// video that lands at the same index in the new result.
|
||||||
setPlaylist(null)
|
function resetPlaylistItemState(): void {
|
||||||
setSelected(new Set())
|
setSelected(new Set())
|
||||||
setItemKinds({})
|
setItemKinds({})
|
||||||
setFormatExpanded(new Set())
|
setFormatExpanded(new Set())
|
||||||
@@ -295,6 +295,14 @@ export function useDownloadBar(): DownloadBarController {
|
|||||||
setFormatProbeError({})
|
setFormatProbeError({})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function clearProbe(): void {
|
||||||
|
setInfo(null)
|
||||||
|
setProbeError(null)
|
||||||
|
setFormatId('')
|
||||||
|
setPlaylist(null)
|
||||||
|
resetPlaylistItemState()
|
||||||
|
}
|
||||||
|
|
||||||
// Reset the whole bar after a download / playlist is enqueued: clear the URL +
|
// Reset the whole bar after a download / playlist is enqueued: clear the URL +
|
||||||
// probe and drop the one-shot overrides (trim / schedule / advanced / incognito /
|
// probe and drop the one-shot overrides (trim / schedule / advanced / incognito /
|
||||||
// per-download options) so the next download starts from the global defaults.
|
// per-download options) so the next download starts from the global defaults.
|
||||||
@@ -387,6 +395,7 @@ export function useDownloadBar(): DownloadBarController {
|
|||||||
setProbeError(null)
|
setProbeError(null)
|
||||||
setInfo(null)
|
setInfo(null)
|
||||||
setPlaylist(null)
|
setPlaylist(null)
|
||||||
|
resetPlaylistItemState()
|
||||||
// Probing may switch the URL to the format-picker path, changing the command.
|
// Probing may switch the URL to the format-picker path, changing the command.
|
||||||
setCommandPreview(null)
|
setCommandPreview(null)
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user