mirror of
https://github.com/jakejarvis/sofa.git
synced 2026-08-29 01:35:39 -04:00
Add /dashboard route, mark-all-watched on complete, keyboard fixes
- Move dashboard page to app/(pages)/dashboard, redirect / to /dashboard for authenticated users, update all nav/breadcrumb/auth hrefs - Mark all episodes watched when a TV show status is set to "completed" (markAllEpisodesWatched skips already-watched episodes) - Refactor KeyboardProvider to store shortcuts in a ref instead of state, eliminating unnecessary re-renders; use react-hotkeys-hook for Cmd+K so it works reliably in form inputs - Fix useRegisterShortcut: re-register on every render (stable ref read) with a separate cleanup effect, removing brittle key memoization - Search page: silently navigate to title detail on import instead of showing "Added to library" toast
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import { useEffect, useMemo } from "react";
|
||||
import { useEffect } from "react";
|
||||
import { type ShortcutDef, useKeyboard } from "@/components/keyboard-provider";
|
||||
|
||||
export function useRegisterShortcut(id: string, def: ShortcutDef) {
|
||||
const { registerShortcut, unregisterShortcut } = useKeyboard();
|
||||
const keysKey = def.keys.join(",");
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: stable memoization on keys/description
|
||||
const stableDef = useMemo(() => def, [keysKey]);
|
||||
|
||||
useEffect(() => {
|
||||
registerShortcut(id, stableDef);
|
||||
registerShortcut(id, def);
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
return () => unregisterShortcut(id);
|
||||
}, [id, registerShortcut, unregisterShortcut, stableDef]);
|
||||
}, [id, unregisterShortcut]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user