fix: handle invalid bookkey for viewState, closes #2073 (#2074)

This commit is contained in:
Huang Xin
2025-09-19 17:09:32 +08:00
committed by GitHub
parent 509320813f
commit 48dc570809
2 changed files with 3 additions and 2 deletions
+2 -1
View File
@@ -65,7 +65,8 @@ export function useSync(bookKey?: string) {
const { syncClient } = useSyncContext();
useEffect(() => {
setIsSyncing(bookKey || '', syncing);
if (!bookKey) return;
setIsSyncing(bookKey, syncing);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [bookKey, syncing]);
+1 -1
View File
@@ -98,7 +98,7 @@ export const useReaderStore = create<ReaderStore>((set, get) => ({
getViewsById: (id: string) => {
const { viewStates } = get();
return Object.values(viewStates)
.filter((state) => state.key.startsWith(id))
.filter((state) => state.key && state.key.startsWith(id))
.map((state) => state.view!);
},