Fix L54/L61/L63: thumbnail error fallback, ipcMain.handle, audioQuality label

L54: DownloadBar preview image now tracks failed src in state (same pattern as
     MediaThumb); on load error shows the kind icon fallback instead of broken img.
L61: Convert taskbarProgress from ipcMain.on/ipcRenderer.send to ipcMain.handle/
     ipcRenderer.invoke so all IPC channels use the same request-response idiom.
     App.tsx calls void to explicitly discard the resolved promise.
L63: audioQuality() now has an explicit 'Best' case alongside the bitrate strings;
     unknown labels still fall back to '0' but the default branch is documented.

typecheck + 242 tests + eslint + prettier green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-30 13:45:45 -04:00
parent 9d816f0c86
commit ba208de98b
7 changed files with 26 additions and 13 deletions
+5 -1
View File
@@ -69,7 +69,11 @@ function App(): React.JSX.Element {
lastFraction = s.progress
lastMode = mode
lastBadge = s.downloading
window.api?.setTaskbarProgress?.({ fraction: s.progress, mode, badgeCount: s.downloading })
void window.api?.setTaskbarProgress?.({
fraction: s.progress,
mode,
badgeCount: s.downloading
})
}
push(useDownloads.getState().items)
return useDownloads.subscribe((st) => push(st.items))
+8 -2
View File
@@ -327,6 +327,7 @@ export function DownloadBar(): React.JSX.Element {
// Probe state for the single-video format picker.
const [info, setInfo] = useState<MediaInfo | null>(null)
const [thumbFailed, setThumbFailed] = useState<string | null>(null)
const [probing, setProbing] = useState(false)
const [probeError, setProbeError] = useState<string | null>(null)
const [formatId, setFormatId] = useState<string>('')
@@ -627,8 +628,13 @@ export function DownloadBar(): React.JSX.Element {
{info && (
<div className={styles.preview}>
{info.thumbnail ? (
<img className={styles.previewThumb} src={info.thumbnail} alt="" />
{info.thumbnail && thumbFailed !== info.thumbnail ? (
<img
className={styles.previewThumb}
src={info.thumbnail}
alt=""
onError={() => setThumbFailed(info.thumbnail ?? null)}
/>
) : (
<div className={styles.previewThumb}>
{kind === 'audio' ? (
+1 -1
View File
@@ -269,7 +269,7 @@ if (import.meta.env.DEV && !window.api) {
runTerminal: async () => ({ ok: true }),
cancelTerminal: async () => {},
onTerminalOutput: () => () => {},
setTaskbarProgress: () => {},
setTaskbarProgress: async () => {},
mintPoToken: async () => null
}
}