fix: maintain library state across reader/library navigation, closes #1072 (#1096)

This commit is contained in:
Huang Xin
2025-05-08 15:26:58 +08:00
committed by GitHub
parent e91a39e8b6
commit 0a562d90ac
+8 -7
View File
@@ -285,16 +285,17 @@ const LibraryPageContent = ({ searchParams }: { searchParams: ReadonlyURLSearchP
const settings = await appService.loadSettings();
setSettings(settings);
const libraryBooks = await appService.loadLibraryBooks();
// Reuse the library from the store when we return from the reader
const library = libraryBooks.length > 0 ? libraryBooks : await appService.loadLibraryBooks();
if (checkOpenWithBooks) {
await handleOpenWithBooks(appService, libraryBooks);
await handleOpenWithBooks(appService, library);
} else {
setCheckOpenWithBooks(false);
setLibrary(libraryBooks);
setLibrary(library);
}
if (checkLastOpenBooks && settings.openLastBooks) {
await handleOpenLastBooks(appService, settings.lastOpenBooks, libraryBooks);
await handleOpenLastBooks(appService, settings.lastOpenBooks, library);
} else {
setCheckLastOpenBooks(false);
}
@@ -304,14 +305,14 @@ const LibraryPageContent = ({ searchParams }: { searchParams: ReadonlyURLSearchP
setLoading(false);
};
const handleOpenWithBooks = async (appService: AppService, libraryBooks: Book[]) => {
const handleOpenWithBooks = async (appService: AppService, library: Book[]) => {
const openWithFiles = (await parseOpenWithFiles()) || [];
if (openWithFiles.length > 0) {
await processOpenWithFiles(appService, openWithFiles, libraryBooks);
await processOpenWithFiles(appService, openWithFiles, library);
} else {
setCheckOpenWithBooks(false);
setLibrary(libraryBooks);
setLibrary(library);
}
};