mirror of
https://github.com/rommapp/romm.git
synced 2026-11-30 02:22:44 +01:00
* Load missing firmware with useAsyncState Replaces the hand-rolled loading ref, try/finally and onMounted fetch in MissingFirmwareSection with VueUse's useAsyncState, as a trial of the pattern for component-local fetches. It also discards a stale response when two fetches overlap. resetOnExecute is disabled so a post-cleanup refetch keeps the current rows up instead of flashing the skeleton, and onError routes failures to the snackbar instead of the default reportError. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J28XLfUSEgeZ6uMDiCL6vy * Add useFetchState and use it for missing firmware useFetchState wraps VueUse's useAsyncState with the defaults v2 wants: a refetch keeps the current data, nothing goes to reportError, and onSuccess/onError only fire for the newest call. useAsyncState fires them for every call, so a stale response could still trim the platform selection in MissingFirmwareSection. The frontend-v2-patterns skill now points components that fetch their own data at it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J28XLfUSEgeZ6uMDiCL6vy * Load v2 component data through useFetchState Moves the self-fetching v2 components onto useFetchState: the streaming, users and client token settings, scan and conversion settings, the library stats widget, the changelog dialog, the text and markdown viewers, and the memory card manager and picker. Each keeps its messages and refetch call sites. A refetch no longer resets their data, and a stale response (an older call, or one for a previous prop value) can no longer overwrite a newer one. useFetchState now runs onSuccess/onError after the newest call has written state, so a callback reads the new data. The client tokens page also shows its loading state from the first render instead of flashing the empty message. InstallOnDeviceDialog keeps its own loader: its guard checks the dialog is still on the same ROM, which a newest-call guard doesn't match. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J28XLfUSEgeZ6uMDiCL6vy * Type useFetchState's immediate run with overloads A fetcher that takes arguments now has to pass immediate: false, so the setup run no longer needs a double cast to call it with no arguments, and forgetting the flag is a type error. Also trims the memory card picker's fetch comment to its non-obvious part. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J28XLfUSEgeZ6uMDiCL6vy * Decide useFetchState's callback from the call's outcome onError used to be picked by checking error for undefined, which is also VueUse's "no error" value, so a fetcher rejecting with no reason ran onSuccess(undefined). useAsyncState now rethrows, and execute catches it, so the outcome is known directly and execute still never throws. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J28XLfUSEgeZ6uMDiCL6vy * Log failed fetches with console.error in converted v2 loaders v2 ships only console.error. The memory card and streaming loaders carried over a console.warn from before the conversion. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J28XLfUSEgeZ6uMDiCL6vy --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>