Add sync status inside editor

This commit is contained in:
Andras Schmelczer 2025-05-11 22:25:19 +01:00
parent 8b22549f5e
commit de346b9fcf
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
4 changed files with 111 additions and 1 deletions

View file

@ -15,8 +15,10 @@ import { SyncClient, rateLimit } from "sync-client";
import { ObsidianFileSystemOperations } from "./obsidian-file-system";
import { SyncSettingsTab } from "./views/settings/settings-tab";
import { registerConsoleForLogging } from "./utils/register-console-for-logging";
import { updateEditorStatusDisplay } from "./views/editor-sync-line/editor-sync-line";
export default class VaultLinkPlugin extends Plugin {
private readonly disposables: (() => void)[] = [];
private settingsTab: SyncSettingsTab | undefined;
private client!: SyncClient;
private readonly rateLimitedUpdatesPerFile = new Map<
@ -74,11 +76,21 @@ export default class VaultLinkPlugin extends Plugin {
this.app.workspace.onLayoutReady(async () => {
this.registerEditorEvents();
void this.client.start();
const interval = setInterval(() => {
updateEditorStatusDisplay(this.app.workspace, this.client);
}, 200);
this.disposables.push(() => {
clearInterval(interval);
});
});
}
public onunload(): void {
this.client.stop();
this.disposables.forEach((disposable) => {
disposable();
});
}
public openSettings(): void {