fix: save reading progress when closing app directly in reader page, closes #2346 (#2461)

This commit is contained in:
Huang Xin
2025-11-17 21:05:56 +05:30
committed by GitHub
parent 04ade02a06
commit c42fcf9ac4
2 changed files with 4 additions and 2 deletions
@@ -138,7 +138,7 @@ const ReaderContent: React.FC<{ ids?: string; settings: SystemSettings }> = ({ i
const handleCloseBooks = throttle(async () => {
const settings = useSettingsStore.getState().settings;
await Promise.all(bookKeys.map((key) => saveConfigAndCloseBook(key)));
await Promise.all(bookKeys.map(async (key) => await saveConfigAndCloseBook(key)));
await saveSettings(envConfig, settings);
}, 200);
@@ -166,6 +166,7 @@ const ReaderContent: React.FC<{ ids?: string; settings: SystemSettings }> = ({ i
const openWithFiles = (await parseOpenWithFiles()) || [];
if (appService?.hasWindow) {
if (openWithFiles.length > 0) {
tauriHandleOnCloseWindow(handleCloseBooks);
return await tauriHandleClose();
}
const currentWindow = getCurrentWindow();
+2 -1
View File
@@ -49,7 +49,8 @@ export const tauriHandleClose = async () => {
export const tauriHandleOnCloseWindow = async (callback: () => void) => {
const currentWindow = getCurrentWindow();
return currentWindow.listen(TauriEvent.WINDOW_CLOSE_REQUESTED, async () => {
return await currentWindow.onCloseRequested(async (event) => {
event.preventDefault();
await callback();
if (currentWindow.label.startsWith('reader')) {
await emitTo('main', 'close-reader-window', { label: currentWindow.label });