Add syncInterval
This commit is contained in:
parent
141db79f3a
commit
c9512ab8b1
4 changed files with 50 additions and 3 deletions
|
|
@ -266,8 +266,9 @@ export class SyncSettingsTab extends PluginSettingTab {
|
||||||
|
|
||||||
new Notice("Checking connection to the server...");
|
new Notice("Checking connection to the server...");
|
||||||
new Notice(
|
new Notice(
|
||||||
(await this.syncClient.checkConnection())
|
(
|
||||||
.serverMessage
|
await this.syncClient.checkConnection()
|
||||||
|
).serverMessage
|
||||||
);
|
);
|
||||||
await this.statusDescription.updateConnectionState();
|
await this.statusDescription.updateConnectionState();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -503,6 +504,47 @@ export class SyncSettingsTab extends PluginSettingTab {
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
new Setting(containerEl)
|
||||||
|
.setName("Sync interval (ms)")
|
||||||
|
.setDesc(
|
||||||
|
"How often to reconcile when no changes are detected. Leave blank to rely on change notifications."
|
||||||
|
)
|
||||||
|
.addText((input) =>
|
||||||
|
input
|
||||||
|
.setPlaceholder("Disabled")
|
||||||
|
.setValue(
|
||||||
|
this.syncClient
|
||||||
|
.getSettings()
|
||||||
|
.syncIntervalMs?.toString() ?? ""
|
||||||
|
)
|
||||||
|
.onChange(async (value) => {
|
||||||
|
if (value === "") {
|
||||||
|
return this.syncClient.setSetting(
|
||||||
|
"syncIntervalMs",
|
||||||
|
undefined
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const parsedValue = Number(value);
|
||||||
|
if (
|
||||||
|
!Number.isSafeInteger(parsedValue) ||
|
||||||
|
parsedValue <= 0
|
||||||
|
) {
|
||||||
|
input.setValue(
|
||||||
|
this.syncClient
|
||||||
|
.getSettings()
|
||||||
|
.syncIntervalMs?.toString() ?? ""
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.syncClient.setSetting(
|
||||||
|
"syncIntervalMs",
|
||||||
|
parsedValue
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private setStatusDescriptionSubscription(
|
private setStatusDescriptionSubscription(
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ export interface SyncSettings {
|
||||||
enableTelemetry: boolean;
|
enableTelemetry: boolean;
|
||||||
requestTimeoutMs: number;
|
requestTimeoutMs: number;
|
||||||
networkRetryIntervalMs: number;
|
networkRetryIntervalMs: number;
|
||||||
|
syncIntervalMs?: number;
|
||||||
minimumSaveIntervalMs: number;
|
minimumSaveIntervalMs: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -31,6 +32,7 @@ export const DEFAULT_SETTINGS: SyncSettings = {
|
||||||
enableTelemetry: false,
|
enableTelemetry: false,
|
||||||
requestTimeoutMs: 30_000,
|
requestTimeoutMs: 30_000,
|
||||||
networkRetryIntervalMs: 1000,
|
networkRetryIntervalMs: 1000,
|
||||||
|
syncIntervalMs: undefined,
|
||||||
minimumSaveIntervalMs: 1000
|
minimumSaveIntervalMs: 1000
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import type { WebSocketClientMessage } from "./types/WebSocketClientMessage";
|
||||||
import type { CursorPositionFromClient } from "./types/CursorPositionFromClient";
|
import type { CursorPositionFromClient } from "./types/CursorPositionFromClient";
|
||||||
import type { ClientCursors } from "./types/ClientCursors";
|
import type { ClientCursors } from "./types/ClientCursors";
|
||||||
import { createPromise } from "../utils/create-promise";
|
import { createPromise } from "../utils/create-promise";
|
||||||
import type { EventBatch } from "./protocol";
|
import type { EventBatch } from "./types/EventBatch";
|
||||||
import { WEBSOCKET_DISCONNECT_TIMEOUT_IN_S } from "../consts";
|
import { WEBSOCKET_DISCONNECT_TIMEOUT_IN_S } from "../consts";
|
||||||
import { removeFromArray } from "../utils/remove-from-array";
|
import { removeFromArray } from "../utils/remove-from-array";
|
||||||
import { EventListeners } from "../utils/data-structures/event-listeners";
|
import { EventListeners } from "../utils/data-structures/event-listeners";
|
||||||
|
|
|
||||||
3
frontend/sync-client/src/types/file-manifest-entries.ts
Normal file
3
frontend/sync-client/src/types/file-manifest-entries.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
import type { FileManifest } from "../services/types/FileManifest";
|
||||||
|
|
||||||
|
export type FileManifestEntries = FileManifest["entries"];
|
||||||
Loading…
Reference in a new issue