From 48ca6e7f7ee4254668f59b5a3b49475b98fac6d9 Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Tue, 25 Mar 2025 21:38:09 +0000 Subject: [PATCH] Delete references to fetchChangesUpdateIntervalMs --- .../obsidian-plugin/src/views/settings-tab.ts | 23 ----------- .../sync-client/src/persistence/settings.ts | 3 -- frontend/sync-client/src/sync-client.ts | 39 ------------------- frontend/test-client/src/agent/mock-agent.ts | 13 +------ 4 files changed, 1 insertion(+), 77 deletions(-) diff --git a/frontend/obsidian-plugin/src/views/settings-tab.ts b/frontend/obsidian-plugin/src/views/settings-tab.ts index 7d726fb5..f539c0b9 100644 --- a/frontend/obsidian-plugin/src/views/settings-tab.ts +++ b/frontend/obsidian-plugin/src/views/settings-tab.ts @@ -246,29 +246,6 @@ export class SyncSettingsTab extends PluginSettingTab { ) ); - new Setting(containerEl) - .setName("Remote fetching frequency (seconds)") - .setDesc( - "Set how often should the plugin check for changes on the server. Lower values will increase the frequency of the checks making it easier to collaborate with others." - ) - .setTooltip("todo, links to docs") - .addSlider((text) => - text - .setLimits(0.5, 60, 0.5) - .setDynamicTooltip() - .setInstant(false) - .setValue( - this.syncClient.getSettings() - .fetchChangesUpdateIntervalMs / 1000 - ) - .onChange(async (value) => - this.syncClient.setSetting( - "fetchChangesUpdateIntervalMs", - value * 1000 - ) - ) - ); - new Setting(containerEl) .setName("Sync concurrency") .setDesc( diff --git a/frontend/sync-client/src/persistence/settings.ts b/frontend/sync-client/src/persistence/settings.ts index b951930d..aecfafc9 100644 --- a/frontend/sync-client/src/persistence/settings.ts +++ b/frontend/sync-client/src/persistence/settings.ts @@ -1,11 +1,9 @@ import type { Logger } from "../tracing/logger"; -import { LogLevel } from "../tracing/logger"; export interface SyncSettings { remoteUri: string; token: string; vaultName: string; - fetchChangesUpdateIntervalMs: number; syncConcurrency: number; isSyncEnabled: boolean; maxFileSizeMB: number; @@ -15,7 +13,6 @@ const DEFAULT_SETTINGS: SyncSettings = { remoteUri: "", token: "", vaultName: "default", - fetchChangesUpdateIntervalMs: 1000, syncConcurrency: 1, isSyncEnabled: false, maxFileSizeMB: 10 diff --git a/frontend/sync-client/src/sync-client.ts b/frontend/sync-client/src/sync-client.ts index 0e0df2ff..6100bc99 100644 --- a/frontend/sync-client/src/sync-client.ts +++ b/frontend/sync-client/src/sync-client.ts @@ -17,8 +17,6 @@ import { ConnectionStatus } from "./services/connection-status"; import { UnrestrictedSyncer } from "./sync-operations/unrestricted-syncer"; export class SyncClient { - private remoteListenerIntervalId: NodeJS.Timeout | null = null; - // eslint-disable-next-line @typescript-eslint/max-params private constructor( private readonly history: SyncHistory, @@ -31,15 +29,6 @@ export class SyncClient { ) { this.settings.addOnSettingsChangeListener( (newSettings, oldSettings) => { - if ( - newSettings.fetchChangesUpdateIntervalMs !== - oldSettings.fetchChangesUpdateIntervalMs - ) { - this.setRemoteEventListener( - newSettings.fetchChangesUpdateIntervalMs - ); - } - if (newSettings.vaultName !== oldSettings.vaultName) { void this.reset(); } @@ -161,27 +150,16 @@ export class SyncClient { public async start(): Promise { await this.syncer.scheduleSyncForOfflineChanges(); - - this.setRemoteEventListener( - this.settings.getSettings().fetchChangesUpdateIntervalMs - ); - } - - /// Clear all global state that has been touched by SyncClient. - public stop(): void { - this.unsetRemoteEventListener(); } public async waitAndStop(): Promise { await this.syncer.waitUntilFinished(); - this.stop(); } /// Wait for the in-flight operations to finish, reset all tracking, /// and the local database but retain the settings. /// The SyncClient can be used again after calling this method. public async reset(): Promise { - this.stop(); this.connectionStatus.startReset(); await this.syncer.reset(); this.history.reset(); @@ -242,21 +220,4 @@ export class SyncClient { relativePath }); } - - private setRemoteEventListener(intervalMs: number): void { - if (this.remoteListenerIntervalId !== null) { - clearInterval(this.remoteListenerIntervalId); - } - - this.remoteListenerIntervalId = setInterval( - () => void this.syncer.applyRemoteChangesLocally(), - intervalMs - ); - } - - private unsetRemoteEventListener(): void { - if (this.remoteListenerIntervalId !== null) { - clearInterval(this.remoteListenerIntervalId); - } - } } diff --git a/frontend/test-client/src/agent/mock-agent.ts b/frontend/test-client/src/agent/mock-agent.ts index 3f7b16d3..945fd7dd 100644 --- a/frontend/test-client/src/agent/mock-agent.ts +++ b/frontend/test-client/src/agent/mock-agent.ts @@ -88,8 +88,7 @@ export class MockAgent extends MockClient { public async act(): Promise { const options: (() => Promise)[] = [ - this.createFileAction.bind(this), - this.changeFetchChangesUpdateIntervalMsAction.bind(this) + this.createFileAction.bind(this) ]; if (this.client.getSettings().isSyncEnabled) { @@ -253,16 +252,6 @@ export class MockAgent extends MockClient { return this.create(file, new TextEncoder().encode(` ${content} `)); } - private async changeFetchChangesUpdateIntervalMsAction(): Promise { - this.client.logger.info( - `Decided to change fetchChangesUpdateIntervalMs` - ); - return this.client.setSetting( - "fetchChangesUpdateIntervalMs", - Math.random() * 2000 + 100 - ); - } - private async disableSyncAction(): Promise { this.client.logger.info(`Decided to disable sync`); await this.client.setSetting("isSyncEnabled", false);