Handle external files

This commit is contained in:
Gregory Schier
2025-02-07 22:14:40 -08:00
parent 266892dc8d
commit c6289f13c1
7 changed files with 97 additions and 33 deletions

View File

@@ -10,6 +10,7 @@ import { jotaiStore } from '../lib/jotai';
export function initSync() {
initModelListeners();
initFileChangeListeners();
sync().catch(console.error);
}
export async function sync({ force }: { force?: boolean } = {}) {
@@ -53,6 +54,7 @@ function initFileChangeListeners() {
await unsub?.(); // Unsub to previous
const workspaceMeta = jotaiStore.get(workspaceMetaAtom);
if (workspaceMeta == null || workspaceMeta.settingSyncDir == null) return;
debouncedSync(); // Perform an initial sync when switching workspace
unsub = watchWorkspaceFiles(
workspaceMeta.workspaceId,
workspaceMeta.settingSyncDir,