fix(store): guard fs-changed listener against setup/missing screens

The module-scope fs-changed listener fired unconditionally, calling
loadLists even when the user was on the setup or missing-workspace
screens (where no current workspace exists). The invoke would fail
silently and a WebDAV debounced sync could kick off against an
incomplete state. Bail when there's no active workspace or the tasks
screen isn't mounted.
This commit is contained in:
Claude 2026-04-17 16:25:39 +00:00
parent 5869c305aa
commit 6283f9ab2c
No known key found for this signature in database

View file

@ -10,10 +10,13 @@ import type {
} from "../types";
import { groupTasksByDate, type TaskGroup } from "../grouping";
// Listen for file system changes from the backend watcher.
// Listen for file system changes from the backend watcher. Guard against
// firing while the user is on the setup/missing screens — loadLists would
// fail (no workspace) and a debouncedSync against a non-synced workspace
// would be wasted work.
listen("fs-changed", () => {
if (!hasWorkspace || screen !== "tasks") return;
loadLists();
// Debounced sync for WebDAV workspaces on local file changes
if (isSyncedWorkspace) debouncedSync();
});