fix: avoid pagination until book view is inited, closes #1983 (#1994)

This commit is contained in:
Huang Xin
2025-09-07 20:47:35 +08:00
committed by GitHub
parent 70a7f5be19
commit 71c2143cba
4 changed files with 25 additions and 3 deletions
+16
View File
@@ -26,6 +26,7 @@ interface ViewState {
view: FoliateView | null;
isPrimary: boolean;
loading: boolean;
inited: boolean;
error: string | null;
progress: BookProgress | null;
ribbonVisible: boolean;
@@ -73,6 +74,7 @@ interface ReaderStore {
getViewState: (key: string) => ViewState | null;
getGridInsets: (key: string) => Insets | null;
setGridInsets: (key: string, insets: Insets | null) => void;
setViewInited: (key: string, inited: boolean) => void;
}
export const useReaderStore = create<ReaderStore>((set, get) => ({
@@ -116,6 +118,7 @@ export const useReaderStore = create<ReaderStore>((set, get) => ({
view: null,
isPrimary: false,
loading: true,
inited: false,
error: null,
progress: null,
ribbonVisible: false,
@@ -173,6 +176,7 @@ export const useReaderStore = create<ReaderStore>((set, get) => ({
view: null,
isPrimary,
loading: false,
inited: false,
error: null,
progress: null,
ribbonVisible: false,
@@ -193,6 +197,7 @@ export const useReaderStore = create<ReaderStore>((set, get) => ({
view: null,
isPrimary: false,
loading: false,
inited: false,
error: 'Failed to load book.',
progress: null,
ribbonVisible: false,
@@ -339,4 +344,15 @@ export const useReaderStore = create<ReaderStore>((set, get) => ({
},
},
})),
setViewInited: (key: string, inited: boolean) =>
set((state) => ({
viewStates: {
...state.viewStates,
[key]: {
...state.viewStates[key]!,
inited,
},
},
})),
}));