Show WebSocket status on UI
This commit is contained in:
parent
a249919061
commit
1a05e184a7
1 changed files with 71 additions and 28 deletions
|
|
@ -8,7 +8,6 @@ import type { RelativePath, StoredDatabase } from "./persistence/database";
|
|||
import { Database } from "./persistence/database";
|
||||
import type { SyncSettings } from "./persistence/settings";
|
||||
import { Settings } from "./persistence/settings";
|
||||
import type { CheckConnectionResult } from "./services/sync-service";
|
||||
import { SyncService } from "./services/sync-service";
|
||||
import { Syncer } from "./sync-operations/syncer";
|
||||
import type { FileSystemOperations } from "./file-operations/filesystem-operations";
|
||||
|
|
@ -16,6 +15,12 @@ import { FileOperations } from "./file-operations/file-operations";
|
|||
import { ConnectionStatus } from "./services/connection-status";
|
||||
import { UnrestrictedSyncer } from "./sync-operations/unrestricted-syncer";
|
||||
|
||||
export interface NetworkConnectionStatus {
|
||||
isSuccessful: boolean;
|
||||
serverMessage: string;
|
||||
isWebSocketConnected: boolean;
|
||||
}
|
||||
|
||||
export class SyncClient {
|
||||
// eslint-disable-next-line @typescript-eslint/max-params
|
||||
private constructor(
|
||||
|
|
@ -134,8 +139,13 @@ export class SyncClient {
|
|||
return client;
|
||||
}
|
||||
|
||||
public async checkConnection(): Promise<CheckConnectionResult> {
|
||||
return this.syncService.checkConnection();
|
||||
public async checkConnection(): Promise<NetworkConnectionStatus> {
|
||||
const server = await this.syncService.checkConnection();
|
||||
return {
|
||||
isSuccessful: server.isSuccessful,
|
||||
serverMessage: server.message,
|
||||
isWebSocketConnected: this.syncer.isWebSocketConnected
|
||||
};
|
||||
}
|
||||
|
||||
public getHistoryEntries(): readonly HistoryEntry[] {
|
||||
|
|
@ -202,6 +212,10 @@ export class SyncClient {
|
|||
this.syncer.addRemainingOperationsListener(listener);
|
||||
}
|
||||
|
||||
public addWebSocketStatusChangeListener(listener: () => void): void {
|
||||
this.syncer.addWebSocketStatusChangeListener(listener);
|
||||
}
|
||||
|
||||
public async syncLocallyCreatedFile(
|
||||
relativePath: RelativePath
|
||||
): Promise<void> {
|
||||
|
|
|
|||
Loading…
Reference in a new issue