Pick up new events API
This commit is contained in:
parent
0a5bbbf20e
commit
504ddb6ff6
7 changed files with 17 additions and 17 deletions
|
|
@ -59,7 +59,7 @@ async function main(): Promise<void> {
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
styleText("VaultLink Local CLI", "bold", "cyan") +
|
styleText("VaultLink Local CLI", "bold", "cyan") +
|
||||||
colorize(` v${packageJson.version}`, "dim")
|
colorize(` v${packageJson.version}`, "dim")
|
||||||
);
|
);
|
||||||
console.log(colorize("=".repeat(50), "dim"));
|
console.log(colorize("=".repeat(50), "dim"));
|
||||||
console.log(
|
console.log(
|
||||||
|
|
@ -153,7 +153,7 @@ async function main(): Promise<void> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add colored log formatter with level filtering
|
// 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
|
// Only show messages at or above the configured log level
|
||||||
if (LOG_LEVEL_ORDER[logLine.level] >= LOG_LEVEL_ORDER[args.logLevel]) {
|
if (LOG_LEVEL_ORDER[logLine.level] >= LOG_LEVEL_ORDER[args.logLevel]) {
|
||||||
console.log(formatLogLine(logLine));
|
console.log(formatLogLine(logLine));
|
||||||
|
|
@ -164,14 +164,14 @@ async function main(): Promise<void> {
|
||||||
|
|
||||||
const fileWatcher = new FileWatcher(absolutePath, client);
|
const fileWatcher = new FileWatcher(absolutePath, client);
|
||||||
|
|
||||||
client.addWebSocketStatusChangeListener(() => {
|
client.onWebSocketStatusChanged.add(() => {
|
||||||
const isConnected = client.isWebSocketConnected;
|
const isConnected = client.isWebSocketConnected;
|
||||||
client.logger.info(
|
client.logger.info(
|
||||||
`WebSocket status changed: ${isConnected ? "connected" : "disconnected"}`
|
`WebSocket status changed: ${isConnected ? "connected" : "disconnected"}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
client.addRemainingSyncOperationsListener((remaining) => {
|
client.onRemainingOperationsCountChanged.add((remaining) => {
|
||||||
if (remaining === 0) {
|
if (remaining === 0) {
|
||||||
client.logger.info("All sync operations completed");
|
client.logger.info("All sync operations completed");
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ export class HistoryView extends ItemView {
|
||||||
super(leaf);
|
super(leaf);
|
||||||
this.icon = HistoryView.ICON;
|
this.icon = HistoryView.ICON;
|
||||||
|
|
||||||
this.client.addSyncHistoryUpdateListener(async () =>
|
this.client.onSyncHistoryUpdated.add(async () =>
|
||||||
this.updateView().catch((error: unknown) => {
|
this.updateView().catch((error: unknown) => {
|
||||||
this.client.logger.error(
|
this.client.logger.error(
|
||||||
`Failed to update history view: ${error}`
|
`Failed to update history view: ${error}`
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ export class LogsView extends ItemView {
|
||||||
) {
|
) {
|
||||||
super(leaf);
|
super(leaf);
|
||||||
this.icon = LogsView.ICON;
|
this.icon = LogsView.ICON;
|
||||||
this.client.logger.addOnMessageListener(() => {
|
this.client.logger.onLogEmitted.add(() => {
|
||||||
this.updateView();
|
this.updateView();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ export class SyncSettingsTab extends PluginSettingTab {
|
||||||
this.editedToken = this.syncClient.getSettings().token;
|
this.editedToken = this.syncClient.getSettings().token;
|
||||||
this.editedVaultName = this.syncClient.getSettings().vaultName;
|
this.editedVaultName = this.syncClient.getSettings().vaultName;
|
||||||
|
|
||||||
this.syncClient.addOnSettingsChangeListener(
|
this.syncClient.onSettingsChanged.add(
|
||||||
(newSettings, oldSettings) => {
|
(newSettings, oldSettings) => {
|
||||||
let hasChanged = false;
|
let hasChanged = false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,19 +14,19 @@ export class StatusBar {
|
||||||
private readonly syncClient: SyncClient
|
private readonly syncClient: SyncClient
|
||||||
) {
|
) {
|
||||||
this.statusBarItem = plugin.addStatusBarItem();
|
this.statusBarItem = plugin.addStatusBarItem();
|
||||||
this.syncClient.addSyncHistoryUpdateListener((status) => {
|
this.syncClient.onSyncHistoryUpdated.add((status) => {
|
||||||
this.lastHistoryStats = status;
|
this.lastHistoryStats = status;
|
||||||
this.updateStatus();
|
this.updateStatus();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.syncClient.addRemainingSyncOperationsListener(
|
this.syncClient.onRemainingOperationsCountChanged.add(
|
||||||
(remainingOperations) => {
|
(remainingOperations) => {
|
||||||
this.lastRemaining = remainingOperations;
|
this.lastRemaining = remainingOperations;
|
||||||
this.updateStatus();
|
this.updateStatus();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
this.syncClient.addOnSettingsChangeListener(() => {
|
this.syncClient.onSettingsChanged.add(() => {
|
||||||
this.updateStatus();
|
this.updateStatus();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,23 +17,23 @@ export class StatusDescription {
|
||||||
public constructor(private readonly syncClient: SyncClient) {
|
public constructor(private readonly syncClient: SyncClient) {
|
||||||
void this.updateConnectionState();
|
void this.updateConnectionState();
|
||||||
|
|
||||||
syncClient.addSyncHistoryUpdateListener((status) => {
|
syncClient.onSyncHistoryUpdated.add((status) => {
|
||||||
this.lastHistoryStats = status;
|
this.lastHistoryStats = status;
|
||||||
this.updateDescription();
|
this.updateDescription();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.syncClient.addRemainingSyncOperationsListener(
|
this.syncClient.onRemainingOperationsCountChanged.add(
|
||||||
(remainingOperations) => {
|
(remainingOperations) => {
|
||||||
this.lastRemaining = remainingOperations;
|
this.lastRemaining = remainingOperations;
|
||||||
this.updateDescription();
|
this.updateDescription();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
this.syncClient.addWebSocketStatusChangeListener(async () =>
|
this.syncClient.onWebSocketStatusChanged.add(async () =>
|
||||||
this.updateConnectionState()
|
this.updateConnectionState()
|
||||||
);
|
);
|
||||||
|
|
||||||
this.syncClient.addOnSettingsChangeListener(async () =>
|
this.syncClient.onSettingsChanged.add(async () =>
|
||||||
this.updateConnectionState()
|
this.updateConnectionState()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ export class MockAgent extends MockClient {
|
||||||
"Connection check failed"
|
"Connection check failed"
|
||||||
);
|
);
|
||||||
|
|
||||||
this.client.logger.addOnMessageListener((logLine: LogLine) => {
|
this.client.logger.onLogEmitted.add((logLine: LogLine) => {
|
||||||
const state = this.client.getSettings().isSyncEnabled
|
const state = this.client.getSettings().isSyncEnabled
|
||||||
? "(online) "
|
? "(online) "
|
||||||
: "(offline)";
|
: "(offline)";
|
||||||
|
|
@ -198,14 +198,14 @@ export class MockAgent extends MockClient {
|
||||||
);
|
);
|
||||||
this.client.logger.info(
|
this.client.logger.info(
|
||||||
"Local files: " +
|
"Local files: " +
|
||||||
Array.from(otherAgent.localFiles.keys()).join(", ")
|
Array.from(otherAgent.localFiles.keys()).join(", ")
|
||||||
);
|
);
|
||||||
otherAgent.client.logger.info(
|
otherAgent.client.logger.info(
|
||||||
"Local data: " + JSON.stringify(otherAgent.data, null, 2)
|
"Local data: " + JSON.stringify(otherAgent.data, null, 2)
|
||||||
);
|
);
|
||||||
otherAgent.client.logger.info(
|
otherAgent.client.logger.info(
|
||||||
"Local files: " +
|
"Local files: " +
|
||||||
Array.from(otherAgent.localFiles.keys()).join(", ")
|
Array.from(otherAgent.localFiles.keys()).join(", ")
|
||||||
);
|
);
|
||||||
|
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue