mirror of
https://github.com/nimbold/Firelink.git
synced 2026-09-11 02:05:45 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8931f14f72 |
+1
-37
@@ -15,8 +15,7 @@ import { getCurrentWindow } from '@tauri-apps/api/window';
|
|||||||
import { initDownloadListener } from './store/downloadStore';
|
import { initDownloadListener } from './store/downloadStore';
|
||||||
import {
|
import {
|
||||||
subscribeToSettingsPersistenceErrors,
|
subscribeToSettingsPersistenceErrors,
|
||||||
useSettingsStore,
|
useSettingsStore
|
||||||
waitForSettingsPersistence
|
|
||||||
} from "./store/useSettingsStore";
|
} from "./store/useSettingsStore";
|
||||||
import { isPermissionGranted, requestPermission, sendNotification } from '@tauri-apps/plugin-notification';
|
import { isPermissionGranted, requestPermission, sendNotification } from '@tauri-apps/plugin-notification';
|
||||||
import { WindowControls } from "./components/WindowControls";
|
import { WindowControls } from "./components/WindowControls";
|
||||||
@@ -40,9 +39,7 @@ import { changeAppLocale, localeDirection, resolveAppLocale, syncDocumentLocale
|
|||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { formatDownloadBytes } from './utils/downloadProgress';
|
import { formatDownloadBytes } from './utils/downloadProgress';
|
||||||
import { synchronizeDocumentAppearance } from './utils/documentAppearance';
|
import { synchronizeDocumentAppearance } from './utils/documentAppearance';
|
||||||
import { createMainWindowSizePersistence } from './utils/mainWindowState';
|
|
||||||
import { createSidebarResizeSession } from './utils/sidebarResize';
|
import { createSidebarResizeSession } from './utils/sidebarResize';
|
||||||
import type { MainWindowSize } from './bindings/MainWindowSize';
|
|
||||||
import {
|
import {
|
||||||
beginSchedulerControl,
|
beginSchedulerControl,
|
||||||
consumeSchedulerHandoffIds,
|
consumeSchedulerHandoffIds,
|
||||||
@@ -494,44 +491,14 @@ function App() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const disposePersistence = initializeDownloadPersistence(getCurrentWindow().label);
|
const disposePersistence = initializeDownloadPersistence(getCurrentWindow().label);
|
||||||
let active = true;
|
let active = true;
|
||||||
let exitRequested = false;
|
|
||||||
let exiting = false;
|
|
||||||
let settingsHydrated = useSettingsStore.persist.hasHydrated();
|
|
||||||
let latestSizeBeforeHydration: MainWindowSize | null = null;
|
|
||||||
const unlistenSettingsHydration = settingsHydrated
|
|
||||||
? null
|
|
||||||
: useSettingsStore.persist.onFinishHydration(() => {
|
|
||||||
settingsHydrated = true;
|
|
||||||
const size = latestSizeBeforeHydration;
|
|
||||||
latestSizeBeforeHydration = null;
|
|
||||||
if (size && active && !exitRequested && !exiting) {
|
|
||||||
useSettingsStore.getState().setMainWindowSize(size);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
const mainWindowSizePersistence = createMainWindowSizePersistence({
|
|
||||||
appWindow: getCurrentWindow(),
|
|
||||||
onSize: size => {
|
|
||||||
if (!active || exiting) return;
|
|
||||||
if (!settingsHydrated) {
|
|
||||||
latestSizeBeforeHydration = size;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
useSettingsStore.getState().setMainWindowSize(size);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
let cleanupListeners: (() => void) | null = null;
|
let cleanupListeners: (() => void) | null = null;
|
||||||
let unlistenExit: (() => void) | null = null;
|
let unlistenExit: (() => void) | null = null;
|
||||||
const exitListener = listen('app-exit-requested', async () => {
|
const exitListener = listen('app-exit-requested', async () => {
|
||||||
exitRequested = true;
|
|
||||||
try {
|
try {
|
||||||
await mainWindowSizePersistence.flush();
|
|
||||||
await waitForSettingsPersistence();
|
|
||||||
await flushDownloadPersistence();
|
await flushDownloadPersistence();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to flush download state before exit:', error);
|
console.error('Failed to flush download state before exit:', error);
|
||||||
} finally {
|
} finally {
|
||||||
exiting = true;
|
|
||||||
latestSizeBeforeHydration = null;
|
|
||||||
await invoke('ack_frontend_exit').catch(error => {
|
await invoke('ack_frontend_exit').catch(error => {
|
||||||
console.error('Failed to acknowledge frontend exit flush:', error);
|
console.error('Failed to acknowledge frontend exit flush:', error);
|
||||||
});
|
});
|
||||||
@@ -550,7 +517,6 @@ function App() {
|
|||||||
let unlistenDeepLink: (() => void) | null = null;
|
let unlistenDeepLink: (() => void) | null = null;
|
||||||
const disposeListeners = () => {
|
const disposeListeners = () => {
|
||||||
void queueFrontendReadyUpdate(false).catch(() => {});
|
void queueFrontendReadyUpdate(false).catch(() => {});
|
||||||
mainWindowSizePersistence.dispose();
|
|
||||||
unlistenExit?.();
|
unlistenExit?.();
|
||||||
unlistenExit = null;
|
unlistenExit = null;
|
||||||
unlistenTerminalState?.();
|
unlistenTerminalState?.();
|
||||||
@@ -756,8 +722,6 @@ function App() {
|
|||||||
cleanupListeners = null;
|
cleanupListeners = null;
|
||||||
unlistenExit?.();
|
unlistenExit?.();
|
||||||
unlistenExit = null;
|
unlistenExit = null;
|
||||||
unlistenSettingsHydration?.();
|
|
||||||
mainWindowSizePersistence.dispose();
|
|
||||||
disposePersistence();
|
disposePersistence();
|
||||||
};
|
};
|
||||||
}, [addToast, enqueueAddInput, processExtensionDownload, queueFrontendReadyUpdate]);
|
}, [addToast, enqueueAddInput, processExtensionDownload, queueFrontendReadyUpdate]);
|
||||||
|
|||||||
Reference in New Issue
Block a user