refactor(renderer): L132 — share resetForm() across download + addPlaylist

Extract the post-enqueue reset (URL + probe + one-shot trim/schedule/advanced/
incognito/options) into resetForm(), called by both download() and addPlaylist().
clearProbe() stays the lighter probe-only reset for onUrlChange. Also fixes a
latent inconsistency: addPlaylist previously left the trim/schedule/advanced
panels open after enqueuing a playlist.

typecheck + eslint + prettier green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-01 11:26:36 -04:00
parent 809c99d5bb
commit 64af608596
2 changed files with 26 additions and 16 deletions
@@ -243,6 +243,24 @@ export function useDownloadBar(): DownloadBarController {
setItemKinds({})
}
// Reset the whole bar after a download / playlist is enqueued: clear the URL +
// probe and drop the one-shot overrides (trim / schedule / advanced / incognito /
// per-download options) so the next download starts from the global defaults.
// Shared by download() and addPlaylist() so a playlist add resets the same state
// a single download does (L132 — addPlaylist previously left trim/schedule open).
function resetForm(): void {
setUrl('')
setTrim('')
setShowTrim(false)
setScheduleAt('')
setShowSchedule(false)
setShowAdvanced(false)
setCommandPreview(null)
setIncognito(false)
setDownloadOptions(DEFAULT_DOWNLOAD_OPTIONS)
clearProbe()
}
// Fetch (or toggle off) the exact yt-dlp command line for the current form
// state. The options mirror what download() sends so the preview matches the
// command that will actually run -- including a probe-selected format and any
@@ -454,19 +472,7 @@ export function useDownloadBar(): DownloadBarController {
})
}
setUrl('')
setTrim('')
setShowTrim(false)
setScheduleAt('')
setShowSchedule(false)
setShowAdvanced(false)
setCommandPreview(null)
// Per-download overrides are one-shot (like trim/schedule): reset so the next
// download starts from the global defaults, and incognito never silently
// carries over to a following download.
setIncognito(false)
setDownloadOptions(DEFAULT_DOWNLOAD_OPTIONS)
clearProbe()
resetForm()
}
function downloadAnyway(): void {
@@ -490,8 +496,7 @@ export function useDownloadBar(): DownloadBarController {
}
})
)
setUrl('')
clearProbe()
resetForm()
}
return {