Expose sync status per file
This commit is contained in:
parent
c9bf983f95
commit
8b22549f5e
4 changed files with 26 additions and 7 deletions
|
|
@ -15,5 +15,6 @@ export type {
|
||||||
} from "./file-operations/filesystem-operations";
|
} from "./file-operations/filesystem-operations";
|
||||||
export type { PersistenceProvider } from "./persistence/persistence";
|
export type { PersistenceProvider } from "./persistence/persistence";
|
||||||
|
|
||||||
export type { NetworkConnectionStatus } from "./sync-client";
|
export type { NetworkConnectionStatus } from "./types/network-connection-status";
|
||||||
|
export { DocumentUpdateStatus } from "./types/document-update-status";
|
||||||
export { SyncClient } from "./sync-client";
|
export { SyncClient } from "./sync-client";
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,8 @@ import { ConnectionStatus } from "./services/connection-status";
|
||||||
import { UnrestrictedSyncer } from "./sync-operations/unrestricted-syncer";
|
import { UnrestrictedSyncer } from "./sync-operations/unrestricted-syncer";
|
||||||
import { rateLimit } from "./utils/rate-limit";
|
import { rateLimit } from "./utils/rate-limit";
|
||||||
import { v4 as uuidv4 } from "uuid";
|
import { v4 as uuidv4 } from "uuid";
|
||||||
|
import { NetworkConnectionStatus } from "./types/network-connection-status";
|
||||||
export interface NetworkConnectionStatus {
|
import { DocumentUpdateStatus } from "./types/document-update-status";
|
||||||
isSuccessful: boolean;
|
|
||||||
serverMessage: string;
|
|
||||||
isWebSocketConnected: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class SyncClient {
|
export class SyncClient {
|
||||||
private static readonly MINIMUM_SAVE_INTERVAL_MS = 1000;
|
private static readonly MINIMUM_SAVE_INTERVAL_MS = 1000;
|
||||||
|
|
@ -260,4 +256,17 @@ export class SyncClient {
|
||||||
relativePath
|
relativePath
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getDocumentSyncingStatus(
|
||||||
|
relativePath: RelativePath
|
||||||
|
): DocumentUpdateStatus {
|
||||||
|
const document =
|
||||||
|
this.database.getLatestDocumentByRelativePath(relativePath);
|
||||||
|
if (document === undefined) {
|
||||||
|
return DocumentUpdateStatus.SYNCING;
|
||||||
|
}
|
||||||
|
return document.updates.length > 0
|
||||||
|
? DocumentUpdateStatus.SYNCING
|
||||||
|
: DocumentUpdateStatus.UP_TO_DATE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
4
frontend/sync-client/src/types/document-update-status.ts
Normal file
4
frontend/sync-client/src/types/document-update-status.ts
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
export enum DocumentUpdateStatus {
|
||||||
|
UP_TO_DATE = "UP_TO_DATE",
|
||||||
|
SYNCING = "SYNCING"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
export interface NetworkConnectionStatus {
|
||||||
|
isSuccessful: boolean;
|
||||||
|
serverMessage: string;
|
||||||
|
isWebSocketConnected: boolean;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue