wait for the pending save before the window closes

the flush was fired and forgotten, so an edit made in the last half second died with the window
This commit is contained in:
2026-11-16 19:46:03 +02:00
parent 0bd1780589
commit a6544eafc0
2 changed files with 13 additions and 2 deletions
+3 -2
View File
@@ -50,8 +50,9 @@ export default function App() {
// The title bar close button skips beforeunload on some platforms
const appWindow = getCurrentWindow();
const unlistenClose = appWindow.onCloseRequested(() => {
useBoardStore.getState().closeBoard();
const unlistenClose = appWindow.onCloseRequested(async () => {
// tauri destroys the window only once this handler settles
await useBoardStore.getState().flushBoard();
});
return () => {
+10
View File
@@ -21,6 +21,7 @@ interface BoardState {
interface BoardActions {
openBoard: (boardId: string) => Promise<void>;
closeBoard: () => void;
flushBoard: () => Promise<void>;
addColumn: (title: string) => void;
updateColumnTitle: (columnId: string, title: string) => void;
@@ -128,6 +129,15 @@ export const useBoardStore = create<BoardState & BoardActions>()(
set({ board: null, saving: false, lastSaved: null });
},
flushBoard: async () => {
if (saveTimeout) {
clearTimeout(saveTimeout);
saveTimeout = null;
}
const { board } = get();
if (board) await saveBoard(board);
},
// -- Column actions --
addColumn: (title: string) => {