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
@@ -65,7 +65,7 @@ const FoliateViewer: React.FC<{
const { themeCode, isDarkMode } = useThemeStore();
const { settings } = useSettingsStore();
const { loadCustomFonts, getLoadedFonts } = useCustomFontStore();
const { getView, setView: setFoliateView, setProgress } = useReaderStore();
const { getView, setView: setFoliateView, setViewInited, setProgress } = useReaderStore();
const { getViewState, getViewSettings, setViewSettings } = useReaderStore();
const { getParallels } = useParallelViewStore();
const { getBookData } = useBookDataStore();
@@ -314,6 +314,7 @@ const FoliateViewer: React.FC<{
} else {
await view.goToFraction(0);
}
setViewInited(bookKey, true);
};
openBook();
@@ -38,13 +38,16 @@ export const usePagination = (
containerRef: React.RefObject<HTMLDivElement>,
) => {
const { appService } = useEnv();
const { getViewSettings } = useReaderStore();
const { getViewSettings, getViewState } = useReaderStore();
const { hoveredBookKey, setHoveredBookKey } = useReaderStore();
const { acquireVolumeKeyInterception, releaseVolumeKeyInterception } = useDeviceControlStore();
const handlePageFlip = async (
msg: MessageEvent | CustomEvent | React.MouseEvent<HTMLDivElement, MouseEvent>,
) => {
const viewState = getViewState(bookKey);
if (!viewState?.inited) return;
if (msg instanceof MessageEvent) {
if (msg.data && msg.data.bookKey === bookKey) {
const viewSettings = getViewSettings(bookKey)!;