diff --git a/frontend/local-client-cli/src/cli.ts b/frontend/local-client-cli/src/cli.ts index 61582a0d..dbede107 100644 --- a/frontend/local-client-cli/src/cli.ts +++ b/frontend/local-client-cli/src/cli.ts @@ -59,7 +59,7 @@ async function main(): Promise { console.log( styleText("VaultLink Local CLI", "bold", "cyan") + - colorize(` v${packageJson.version}`, "dim") + colorize(` v${packageJson.version}`, "dim") ); console.log(colorize("=".repeat(50), "dim")); console.log( @@ -153,7 +153,7 @@ async function main(): Promise { } // Add colored log formatter with level filtering - client.logger.addOnMessageListener((logLine) => { + client.logger.onLogEmitted.add((logLine) => { // Only show messages at or above the configured log level if (LOG_LEVEL_ORDER[logLine.level] >= LOG_LEVEL_ORDER[args.logLevel]) { console.log(formatLogLine(logLine)); @@ -164,14 +164,14 @@ async function main(): Promise { const fileWatcher = new FileWatcher(absolutePath, client); - client.addWebSocketStatusChangeListener(() => { + client.onWebSocketStatusChanged.add(() => { const isConnected = client.isWebSocketConnected; client.logger.info( `WebSocket status changed: ${isConnected ? "connected" : "disconnected"}` ); }); - client.addRemainingSyncOperationsListener((remaining) => { + client.onRemainingOperationsCountChanged.add((remaining) => { if (remaining === 0) { client.logger.info("All sync operations completed"); } else { diff --git a/frontend/obsidian-plugin/src/views/history/history-view.ts b/frontend/obsidian-plugin/src/views/history/history-view.ts index 1fc2c91e..65049f77 100644 --- a/frontend/obsidian-plugin/src/views/history/history-view.ts +++ b/frontend/obsidian-plugin/src/views/history/history-view.ts @@ -24,7 +24,7 @@ export class HistoryView extends ItemView { super(leaf); this.icon = HistoryView.ICON; - this.client.addSyncHistoryUpdateListener(async () => + this.client.onSyncHistoryUpdated.add(async () => this.updateView().catch((error: unknown) => { this.client.logger.error( `Failed to update history view: ${error}` diff --git a/frontend/obsidian-plugin/src/views/logs/logs-view.ts b/frontend/obsidian-plugin/src/views/logs/logs-view.ts index 927dc9b7..83c41b66 100644 --- a/frontend/obsidian-plugin/src/views/logs/logs-view.ts +++ b/frontend/obsidian-plugin/src/views/logs/logs-view.ts @@ -21,7 +21,7 @@ export class LogsView extends ItemView { ) { super(leaf); this.icon = LogsView.ICON; - this.client.logger.addOnMessageListener(() => { + this.client.logger.onLogEmitted.add(() => { this.updateView(); }); } diff --git a/frontend/obsidian-plugin/src/views/settings/settings-tab.ts b/frontend/obsidian-plugin/src/views/settings/settings-tab.ts index afd2b0b0..0eeb166a 100644 --- a/frontend/obsidian-plugin/src/views/settings/settings-tab.ts +++ b/frontend/obsidian-plugin/src/views/settings/settings-tab.ts @@ -41,7 +41,7 @@ export class SyncSettingsTab extends PluginSettingTab { this.editedToken = this.syncClient.getSettings().token; this.editedVaultName = this.syncClient.getSettings().vaultName; - this.syncClient.addOnSettingsChangeListener( + this.syncClient.onSettingsChanged.add( (newSettings, oldSettings) => { let hasChanged = false; diff --git a/frontend/obsidian-plugin/src/views/status-bar/status-bar.ts b/frontend/obsidian-plugin/src/views/status-bar/status-bar.ts index 7a128ae9..8c441f9b 100644 --- a/frontend/obsidian-plugin/src/views/status-bar/status-bar.ts +++ b/frontend/obsidian-plugin/src/views/status-bar/status-bar.ts @@ -14,19 +14,19 @@ export class StatusBar { private readonly syncClient: SyncClient ) { this.statusBarItem = plugin.addStatusBarItem(); - this.syncClient.addSyncHistoryUpdateListener((status) => { + this.syncClient.onSyncHistoryUpdated.add((status) => { this.lastHistoryStats = status; this.updateStatus(); }); - this.syncClient.addRemainingSyncOperationsListener( + this.syncClient.onRemainingOperationsCountChanged.add( (remainingOperations) => { this.lastRemaining = remainingOperations; this.updateStatus(); } ); - this.syncClient.addOnSettingsChangeListener(() => { + this.syncClient.onSettingsChanged.add(() => { this.updateStatus(); }); } diff --git a/frontend/obsidian-plugin/src/views/status-description/status-description.ts b/frontend/obsidian-plugin/src/views/status-description/status-description.ts index 540d5f21..53fea486 100644 --- a/frontend/obsidian-plugin/src/views/status-description/status-description.ts +++ b/frontend/obsidian-plugin/src/views/status-description/status-description.ts @@ -17,23 +17,23 @@ export class StatusDescription { public constructor(private readonly syncClient: SyncClient) { void this.updateConnectionState(); - syncClient.addSyncHistoryUpdateListener((status) => { + syncClient.onSyncHistoryUpdated.add((status) => { this.lastHistoryStats = status; this.updateDescription(); }); - this.syncClient.addRemainingSyncOperationsListener( + this.syncClient.onRemainingOperationsCountChanged.add( (remainingOperations) => { this.lastRemaining = remainingOperations; this.updateDescription(); } ); - this.syncClient.addWebSocketStatusChangeListener(async () => + this.syncClient.onWebSocketStatusChanged.add(async () => this.updateConnectionState() ); - this.syncClient.addOnSettingsChangeListener(async () => + this.syncClient.onSettingsChanged.add(async () => this.updateConnectionState() ); } diff --git a/frontend/test-client/src/agent/mock-agent.ts b/frontend/test-client/src/agent/mock-agent.ts index 7926672e..604c3742 100644 --- a/frontend/test-client/src/agent/mock-agent.ts +++ b/frontend/test-client/src/agent/mock-agent.ts @@ -42,7 +42,7 @@ export class MockAgent extends MockClient { "Connection check failed" ); - this.client.logger.addOnMessageListener((logLine: LogLine) => { + this.client.logger.onLogEmitted.add((logLine: LogLine) => { const state = this.client.getSettings().isSyncEnabled ? "(online) " : "(offline)"; @@ -198,14 +198,14 @@ export class MockAgent extends MockClient { ); this.client.logger.info( "Local files: " + - Array.from(otherAgent.localFiles.keys()).join(", ") + Array.from(otherAgent.localFiles.keys()).join(", ") ); otherAgent.client.logger.info( "Local data: " + JSON.stringify(otherAgent.data, null, 2) ); otherAgent.client.logger.info( "Local files: " + - Array.from(otherAgent.localFiles.keys()).join(", ") + Array.from(otherAgent.localFiles.keys()).join(", ") ); throw e;