1
0

Space sync now scheduled

This commit is contained in:
Zef Hemel 2023-08-15 20:24:02 +02:00
parent 7cce83b240
commit bd77f2932c
6 changed files with 14 additions and 10 deletions

View File

@ -133,10 +133,6 @@ export function vimEx(exCommand: string): Promise<any> {
return syscall("editor.vimEx", exCommand); return syscall("editor.vimEx", exCommand);
} }
export function syncSpace(): Promise<number> {
return syscall("editor.syncSpace");
}
// Folding // Folding
export function fold() { export function fold() {

View File

@ -11,3 +11,7 @@ export function hasInitialSyncCompleted(): Promise<boolean> {
export function scheduleFileSync(path: string): Promise<void> { export function scheduleFileSync(path: string): Promise<void> {
return syscall("sync.scheduleFileSync", path); return syscall("sync.scheduleFileSync", path);
} }
export function scheduleSpaceSync(): Promise<number> {
return syscall("sync.scheduleSpaceSync");
}

View File

@ -1,7 +1,7 @@
import { editor } from "$sb/silverbullet-syscall/mod.ts"; import { editor, sync } from "$sb/silverbullet-syscall/mod.ts";
export async function syncSpaceCommand() { export async function syncSpaceCommand() {
await editor.flashNotification("Syncing space..."); await editor.flashNotification("Syncing space...");
await editor.syncSpace(); await sync.scheduleSpaceSync();
await editor.flashNotification("Done."); await editor.flashNotification("Done.");
} }

View File

@ -166,6 +166,11 @@ export class SyncService {
this.filesScheduledForSync.delete(path); this.filesScheduledForSync.delete(path);
} }
async scheduleSpaceSync(): Promise<void> {
await this.noOngoingSync(5000);
await this.syncSpace();
}
start() { start() {
this.syncSpace().catch(console.error); this.syncSpace().catch(console.error);

View File

@ -184,10 +184,6 @@ export function editorSyscalls(editor: Client): SysCallMapping {
const cm = vimGetCm(editor.editorView)!; const cm = vimGetCm(editor.editorView)!;
return Vim.handleEx(cm, exCommand); return Vim.handleEx(cm, exCommand);
}, },
// Sync
"editor.syncSpace": () => {
return editor.syncService.syncSpace();
},
// Folding // Folding
"editor.fold": () => { "editor.fold": () => {
foldCode(editor.editorView); foldCode(editor.editorView);

View File

@ -12,5 +12,8 @@ export function syncSyscalls(editor: Client): SysCallMapping {
"sync.scheduleFileSync": (_ctx, path: string): Promise<void> => { "sync.scheduleFileSync": (_ctx, path: string): Promise<void> => {
return editor.syncService.scheduleFileSync(path); return editor.syncService.scheduleFileSync(path);
}, },
"sync.scheduleSpaceSync": () => {
return editor.syncService.scheduleSpaceSync();
},
}; };
} }