fix: address code review findings - data loss, race condition, broken features

- TopBar: call closeBoard() before navigating back to prevent data loss
- board-store: guard debouncedSave against race condition when board is
  closed during an in-flight save
- board-store: add missing updatedAt to setColumnWidth
- useKeyboardShortcuts: remove duplicate Ctrl+K handler that prevented
  command palette from toggling closed
- AttachmentSection: wire up Tauri file dialog for adding attachments
  with link/copy mode support
This commit is contained in:
Your Name
2026-02-15 19:33:25 +02:00
parent 2a81849c8d
commit c590146be0
4 changed files with 38 additions and 14 deletions

View File

@@ -63,6 +63,7 @@ function now(): string {
function debouncedSave(
board: Board,
get: () => BoardState & BoardActions,
set: (partial: Partial<BoardState>) => void
): void {
if (saveTimeout) clearTimeout(saveTimeout);
@@ -70,9 +71,14 @@ function debouncedSave(
set({ saving: true });
try {
await saveBoard(board);
set({ saving: false, lastSaved: Date.now() });
// Only update state if the same board is still loaded
if (get().board?.id === board.id) {
set({ saving: false, lastSaved: Date.now() });
}
} catch {
set({ saving: false });
if (get().board?.id === board.id) {
set({ saving: false });
}
}
}, 500);
}
@@ -86,7 +92,7 @@ function mutate(
if (!board) return;
const updated = updater(board);
set({ board: updated });
debouncedSave(updated, set);
debouncedSave(updated, get, set);
}
export const useBoardStore = create<BoardState & BoardActions>()(
@@ -166,6 +172,7 @@ export const useBoardStore = create<BoardState & BoardActions>()(
setColumnWidth: (columnId, width) => {
mutate(get, set, (b) => ({
...b,
updatedAt: now(),
columns: b.columns.map((c) =>
c.id === columnId ? { ...c, width } : c
),