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:
+6
-1
@@ -770,7 +770,12 @@ token system + shared primitives (UI/SIMP — high value, larger effort) · i18n
|
|||||||
"interrupted"); user-facing ones are capitalized with periods. Fine when interpolated, jarring if shown raw.
|
"interrupted"); user-facing ones are capitalized with periods. Fine when interpolated, jarring if shown raw.
|
||||||
- [ ] **L131 — Taskbar `error` state is ephemeral** — it's driven by live `error` items, so "Clear
|
- [ ] **L131 — Taskbar `error` state is ephemeral** — it's driven by live `error` items, so "Clear
|
||||||
finished" flips the red taskbar bar back to normal even though failures occurred (out of sync with the persisted error log).
|
finished" flips the red taskbar bar back to normal even though failures occurred (out of sync with the persisted error log).
|
||||||
- [ ] **L132 — `clearProbe` + form-reset logic is duplicated** in DownloadBar (`onUrlChange`, `download`, `addPlaylist`).
|
- [x] **L132 — `clearProbe` + form-reset logic is duplicated** in DownloadBar (`onUrlChange`, `download`, `addPlaylist`).
|
||||||
|
*Fixed: a shared `resetForm()` in [useDownloadBar.ts](src/renderer/src/components/downloadBar/useDownloadBar.ts)
|
||||||
|
now owns the post-enqueue reset (URL + probe + the one-shot trim/schedule/advanced/incognito/options),
|
||||||
|
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.*
|
||||||
- [ ] **L133 — `Field` controls mix `aria-label` + visible `label`.** Many `Field label="X"` wrap a
|
- [ ] **L133 — `Field` controls mix `aria-label` + visible `label`.** Many `Field label="X"` wrap a
|
||||||
`Select aria-label="X"`, so AT announces the name twice (extends M20 across DownloadOptionsForm).
|
`Select aria-label="X"`, so AT announces the name twice (extends M20 across DownloadOptionsForm).
|
||||||
- [ ] **L134 — Inconsistent disabled affordance for busy buttons.** Some stay enabled-looking with a
|
- [ ] **L134 — Inconsistent disabled affordance for busy buttons.** Some stay enabled-looking with a
|
||||||
|
|||||||
@@ -243,6 +243,24 @@ export function useDownloadBar(): DownloadBarController {
|
|||||||
setItemKinds({})
|
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
|
// 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
|
// state. The options mirror what download() sends so the preview matches the
|
||||||
// command that will actually run -- including a probe-selected format and any
|
// command that will actually run -- including a probe-selected format and any
|
||||||
@@ -454,19 +472,7 @@ export function useDownloadBar(): DownloadBarController {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
setUrl('')
|
resetForm()
|
||||||
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()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function downloadAnyway(): void {
|
function downloadAnyway(): void {
|
||||||
@@ -490,8 +496,7 @@ export function useDownloadBar(): DownloadBarController {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
setUrl('')
|
resetForm()
|
||||||
clearProbe()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user