Fix L19/L73: replace setTimeout focus hack with double-rAF; unify probe verb
L19: App.tsx replaced `setTimeout(() => focus(), 60)` in the "New download"
palette action with `requestAnimationFrame(() => requestAnimationFrame(...))`
to wait exactly one React render + paint cycle rather than an arbitrary 60ms
timer that could race on slow machines.
L73: DownloadBar's probe button label changed from "Fetch" to "Check URL" (hint
and aria-label both updated). Placeholder text updated to match. This
distinguishes it from LibraryView's "Index" action, which catalogs an entire
channel/playlist, making both labels clearly meaningful in context.
typecheck + 242 tests green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useState, useEffect, useMemo } from 'react'
|
||||
import { useState, useEffect, useMemo } from 'react'
|
||||
import { FluentProvider, makeStyles, tokens } from '@fluentui/react-components'
|
||||
import { Sidebar, type TabValue } from './components/Sidebar'
|
||||
import { DownloadsView } from './components/DownloadsView'
|
||||
@@ -57,7 +57,7 @@ function App(): React.JSX.Element {
|
||||
|
||||
// Mirror overall queue progress onto the Windows taskbar. Subscribe to the store
|
||||
// directly (not via a selector) so taskbar updates don't re-render the app.
|
||||
// Compare against the last IPC call and skip when nothing changed — the store
|
||||
// Compare against the last IPC call and skip when nothing changed -- the store
|
||||
// fires on every progress tick and this avoids one IPC roundtrip per tick (L25).
|
||||
useEffect(() => {
|
||||
let lastFraction = -1
|
||||
@@ -80,7 +80,7 @@ function App(): React.JSX.Element {
|
||||
return useDownloads.subscribe((st) => push(st.items))
|
||||
}, [])
|
||||
|
||||
// Memoized so CommandPalette sees a stable array reference between renders —
|
||||
// Memoized so CommandPalette sees a stable array reference between renders --
|
||||
// only rebuilds when the theme label needs to change (L32).
|
||||
const paletteActions = useMemo<PaletteAction[]>(
|
||||
() => [
|
||||
@@ -110,8 +110,10 @@ function App(): React.JSX.Element {
|
||||
hint: 'Focus URL',
|
||||
run: () => {
|
||||
setTab('downloads')
|
||||
// Wait for the download bar to mount after the tab switch, then focus.
|
||||
setTimeout(() => document.getElementById('aerofetch-url')?.focus(), 60)
|
||||
// Double-rAF waits for React's re-render + the browser's paint before focusing.
|
||||
requestAnimationFrame(() =>
|
||||
requestAnimationFrame(() => document.getElementById('aerofetch-url')?.focus())
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -555,17 +555,17 @@ export function DownloadBar(): React.JSX.Element {
|
||||
if (info || probeError || playlist) download()
|
||||
else void fetchFormats()
|
||||
}}
|
||||
placeholder="Paste a video or playlist URL, then fetch…"
|
||||
placeholder="Paste a video or playlist URL, then check…"
|
||||
size="large"
|
||||
contentBefore={<ArrowDownloadRegular />}
|
||||
/>
|
||||
<Hint label="Fetch formats / playlist" placement="bottom" align="end">
|
||||
<Hint label="Check URL" placement="bottom" align="end">
|
||||
<Button
|
||||
size="large"
|
||||
icon={probing ? <Spinner size="tiny" /> : <SearchRegular />}
|
||||
onClick={fetchFormats}
|
||||
disabled={!url.trim() || probing}
|
||||
aria-label="Fetch formats or playlist"
|
||||
aria-label="Check URL for formats or playlist"
|
||||
/>
|
||||
</Hint>
|
||||
<Hint label="Paste from clipboard" placement="bottom" align="end">
|
||||
|
||||
Reference in New Issue
Block a user