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:
parent
5869c305aa
commit
6283f9ab2c
|
|
@ -10,10 +10,13 @@ import type {
|
||||||
} from "../types";
|
} from "../types";
|
||||||
import { groupTasksByDate, type TaskGroup } from "../grouping";
|
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", () => {
|
listen("fs-changed", () => {
|
||||||
|
if (!hasWorkspace || screen !== "tasks") return;
|
||||||
loadLists();
|
loadLists();
|
||||||
// Debounced sync for WebDAV workspaces on local file changes
|
|
||||||
if (isSyncedWorkspace) debouncedSync();
|
if (isSyncedWorkspace) debouncedSync();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue