This commit is contained in:
Andras Schmelczer 2025-11-23 15:13:30 +00:00
parent 5a0c64d39c
commit fb2d82a06e
6 changed files with 18 additions and 16 deletions

View file

@ -1,8 +1,9 @@
import type { Stat, Vault, Workspace } from "obsidian";
import { MarkdownView, normalizePath } from "obsidian";
import {
import type {
CursorPosition,
TextWithCursors,
TextWithCursors} from "sync-client";
import {
utils,
type FileSystemOperations,
type RelativePath

View file

@ -38,7 +38,7 @@ export default class VaultLinkPlugin extends Plugin {
() => Promise<unknown>
>();
private syncClient: SyncClient | undefined;
private readonly syncClient: SyncClient | undefined;
private settingsTab: SyncSettingsTab | undefined;
public async onload(): Promise<void> {
@ -152,7 +152,7 @@ export default class VaultLinkPlugin extends Plugin {
this.registerView(HistoryView.TYPE, (leaf) => {
const view = new HistoryView(client, leaf);
this.register(() => view.onClose());
this.register(async () => view.onClose());
return view;
});
@ -180,7 +180,7 @@ export default class VaultLinkPlugin extends Plugin {
this.app.workspace,
client
);
this.register(() => editorStatusDisplayManager.dispose());
this.register(() => { editorStatusDisplayManager.dispose(); });
}
private addRibbonIcons(): void {

View file

@ -106,7 +106,7 @@ describe("FetchController", () => {
const controller = new FetchController(true, logger);
assert.throws(
() => controller.finishReset(),
() => { controller.finishReset(); },
(error: unknown) =>
error instanceof Error &&
error.message === "Cannot finish reset when not resetting"

View file

@ -5,7 +5,7 @@ import type { WebSocketClientMessage } from "./types/WebSocketClientMessage";
import type { CursorPositionFromClient } from "./types/CursorPositionFromClient";
import type { ClientCursors } from "./types/ClientCursors";
import { createPromise } from "../utils/create-promise";
import { WebSocketVaultUpdate } from "./types/WebSocketVaultUpdate";
import type { WebSocketVaultUpdate } from "./types/WebSocketVaultUpdate";
export class WebSocketManager {
private readonly webSocketStatusChangeListeners: ((
@ -26,7 +26,7 @@ export class WebSocketManager {
private resolveDisconnectingPromise: null | (() => unknown) = null;
private reconnectTimeoutId: ReturnType<typeof setTimeout> | undefined;
private readonly outstandingPromises: Array<Promise<unknown>> = [];
private readonly outstandingPromises: Promise<unknown>[] = [];
private readonly webSocketFactoryImplementation: typeof globalThis.WebSocket;
public constructor(
@ -104,7 +104,7 @@ export class WebSocketManager {
public sendHandshakeMessage(
message: WebSocketClientMessage & { type: "handshake" }
): void {
const webSocket = this.webSocket;
const {webSocket} = this;
if (!webSocket) {
throw new Error(
"WebSocket is not connected, cannot send handshake message"
@ -126,7 +126,7 @@ export class WebSocketManager {
type: "cursorPositions",
...cursorPositions
};
const webSocket = this.webSocket;
const {webSocket} = this;
if (!webSocket) {
this.logger.warn(
"WebSocket is not connected, cannot send cursor positions"
@ -194,7 +194,7 @@ export class WebSocketManager {
): Promise<void> {
if (message.type === "vaultUpdate") {
this.outstandingPromises.push(
...this.remoteVaultUpdateListeners.map((listener) =>
...this.remoteVaultUpdateListeners.map(async (listener) =>
listener(message)
)
);
@ -204,7 +204,7 @@ export class WebSocketManager {
`Received cursor positions for ${JSON.stringify(message.clients)}`
);
this.outstandingPromises.push(
...this.remoteCursorsUpdateListeners.map((listener) =>
...this.remoteCursorsUpdateListeners.map(async (listener) =>
listener(
message.clients.filter(
(client) => client.deviceId !== this.deviceId

View file

@ -77,7 +77,7 @@ export class SyncClient {
// Missing values will be filled in from DEFAULT_SETTINGS rather than
// retaining current in-memory settings.
public async reloadSettings(): Promise<void> {
let state = (await this.persistence.load()) ?? {
const state = (await this.persistence.load()) ?? {
settings: undefined
};

View file

@ -1,11 +1,12 @@
import type { StoredDatabase } from "sync-client";
import type { StoredDatabase ,
TextWithCursors
} from "sync-client";
import { assert } from "../utils/assert";
import {
type RelativePath,
type FileSystemOperations,
type SyncSettings,
SyncClient,
TextWithCursors
SyncClient
} from "sync-client";
export class MockClient implements FileSystemOperations {