From 49f2d69e598cd0177b6f9808b78bd2010eae02fb Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Sat, 23 Aug 2025 09:49:48 +0100 Subject: [PATCH] Rename types --- .../src/views/cursors/remote-cursors-plugin.ts | 7 ++----- .../src/views/editor-sync-line/editor-sync-line.ts | 4 ++-- frontend/sync-client/src/index.ts | 4 ++-- .../{document-update-status.ts => document-sync-status.ts} | 2 +- frontend/sync-client/src/types/document-up-to-dateness.ts | 5 +++++ .../sync-client/src/types/maybe-outdated-client-cursors.ts | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) rename frontend/sync-client/src/types/{document-update-status.ts => document-sync-status.ts} (59%) create mode 100644 frontend/sync-client/src/types/document-up-to-dateness.ts diff --git a/frontend/obsidian-plugin/src/views/cursors/remote-cursors-plugin.ts b/frontend/obsidian-plugin/src/views/cursors/remote-cursors-plugin.ts index 661aa452..869cbef9 100644 --- a/frontend/obsidian-plugin/src/views/cursors/remote-cursors-plugin.ts +++ b/frontend/obsidian-plugin/src/views/cursors/remote-cursors-plugin.ts @@ -9,10 +9,7 @@ import type { ViewUpdate } from "@codemirror/view"; import { RemoteCursorWidget } from "./remote-cursor-widget"; -import type { - CursorSpan, - DocumentWithMaybeOutdatedClientCursors -} from "sync-client"; +import type { CursorSpan, MaybeOutdatedClientCursors } from "sync-client"; import type { App } from "obsidian"; import { MarkdownView } from "obsidian"; @@ -120,7 +117,7 @@ export const remoteCursorsPlugin = ViewPlugin.fromClass( ); export function setCursors( - clients: DocumentWithMaybeOutdatedClientCursors[], + clients: MaybeOutdatedClientCursors[], app: App ): void { cursors = [ diff --git a/frontend/obsidian-plugin/src/views/editor-sync-line/editor-sync-line.ts b/frontend/obsidian-plugin/src/views/editor-sync-line/editor-sync-line.ts index 67750687..78ef1bd8 100644 --- a/frontend/obsidian-plugin/src/views/editor-sync-line/editor-sync-line.ts +++ b/frontend/obsidian-plugin/src/views/editor-sync-line/editor-sync-line.ts @@ -1,7 +1,7 @@ import type { Workspace } from "obsidian"; import { FileView, setIcon } from "obsidian"; import type { SyncClient } from "sync-client"; -import { DocumentUpdateStatus } from "sync-client"; +import { DocumentSyncStatus } from "sync-client"; import "./editor-sync-line.scss"; export function updateEditorStatusDisplay( @@ -35,7 +35,7 @@ export function updateEditorStatusDisplay( const isLoading = client.getDocumentSyncingStatus(filePath) == - DocumentUpdateStatus.SYNCING; + DocumentSyncStatus.SYNCING; if (isLoading) { element.classList.add("loading"); diff --git a/frontend/sync-client/src/index.ts b/frontend/sync-client/src/index.ts index ce903f25..00b19940 100644 --- a/frontend/sync-client/src/index.ts +++ b/frontend/sync-client/src/index.ts @@ -18,8 +18,8 @@ export type { PersistenceProvider } from "./persistence/persistence"; export type { CursorSpan } from "./services/types/CursorSpan"; export type { ClientCursors } from "./services/types/ClientCursors"; export type { NetworkConnectionStatus } from "./types/network-connection-status"; -export type { DocumentWithMaybeOutdatedClientCursors } from "./types/maybe-outdated-client-cursors"; -export { DocumentUpdateStatus } from "./types/document-update-status"; +export type { MaybeOutdatedClientCursors } from "./types/maybe-outdated-client-cursors"; +export { DocumentSyncStatus } from "./types/document-sync-status"; export { SyncClient } from "./sync-client"; import { Locks } from "./utils/locks"; diff --git a/frontend/sync-client/src/types/document-update-status.ts b/frontend/sync-client/src/types/document-sync-status.ts similarity index 59% rename from frontend/sync-client/src/types/document-update-status.ts rename to frontend/sync-client/src/types/document-sync-status.ts index 7fa1c888..a2ec01c2 100644 --- a/frontend/sync-client/src/types/document-update-status.ts +++ b/frontend/sync-client/src/types/document-sync-status.ts @@ -1,4 +1,4 @@ -export enum DocumentUpdateStatus { +export enum DocumentSyncStatus { UP_TO_DATE = "UP_TO_DATE", SYNCING = "SYNCING" } diff --git a/frontend/sync-client/src/types/document-up-to-dateness.ts b/frontend/sync-client/src/types/document-up-to-dateness.ts new file mode 100644 index 00000000..2f93f9b4 --- /dev/null +++ b/frontend/sync-client/src/types/document-up-to-dateness.ts @@ -0,0 +1,5 @@ +export enum DocumentUpToDateness { + UpToDate = "UpToDate", // easiest case, the client can just show the cursors as-is + Prior = "Prior", // The cursors are outdated, so the client has to guess the cursor positions based on local updates. This is only possible if this client's cursor has once been up-to-date in a given document. + Later = "Later" // The cursors are from a future version of a document, there's no way we can accuratly show them locally. +} diff --git a/frontend/sync-client/src/types/maybe-outdated-client-cursors.ts b/frontend/sync-client/src/types/maybe-outdated-client-cursors.ts index acced952..e062f84e 100644 --- a/frontend/sync-client/src/types/maybe-outdated-client-cursors.ts +++ b/frontend/sync-client/src/types/maybe-outdated-client-cursors.ts @@ -1,5 +1,5 @@ import type { ClientCursors } from "../services/types/ClientCursors"; -export interface DocumentWithMaybeOutdatedClientCursors extends ClientCursors { +export interface MaybeOutdatedClientCursors extends ClientCursors { isOutdated: boolean; }