forked from akai/readest
When a book's underlying file is missing, opening it in a dedicated reader window showed an error toast then navigated that window to /library, leaving a leftover library-in-reader-window the user had to close manually. Route the recovery through a new closeReaderWindowOrGoToLibrary() that closes the dedicated reader window (after ensuring the main library window is visible) and only falls back to /library navigation in the main window or on web. Also fix a related macOS issue: the reader's CloseRequested handler was running handleCloseBooks and calling currentWindow.destroy() on the main window, which tore down the active book and bypassed the Rust close-to-hide handler — making Cmd+W / traffic-light close quit the app from the reader page (vs. correctly hiding from the library page) and lose the active book even when the window did hide. Skip both the cleanup and destroy on macOS for the main window so the Rust handler hides it with the book intact, matching the macOS minimize-to-dock convention. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -20,7 +20,11 @@ import { isTauriAppPlatform } from '@/services/environment';
|
||||
import { uniqueId } from '@/utils/misc';
|
||||
import { throttle } from '@/utils/throttle';
|
||||
import { eventDispatcher } from '@/utils/event';
|
||||
import { ensureMainLibraryWindow, navigateToLibrary } from '@/utils/nav';
|
||||
import {
|
||||
closeReaderWindowOrGoToLibrary,
|
||||
ensureMainLibraryWindow,
|
||||
navigateToLibrary,
|
||||
} from '@/utils/nav';
|
||||
import { clearDiscordPresence } from '@/utils/discord';
|
||||
import { BOOK_IDS_SEPARATOR } from '@/services/constants';
|
||||
import { BookDetailModal } from '@/components/metadata';
|
||||
@@ -74,7 +78,10 @@ const ReaderContent: React.FC<{ ids?: string; settings: SystemSettings }> = ({ i
|
||||
setErrorLoading(true);
|
||||
eventDispatcher.dispatch('toast', {
|
||||
message: _('Unable to open book'),
|
||||
callback: () => navigateBackToLibrary(),
|
||||
callback: async () => {
|
||||
const service = await envConfig.getAppService();
|
||||
await closeReaderWindowOrGoToLibrary(service, router);
|
||||
},
|
||||
timeout: 2000,
|
||||
type: 'error',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user