Add syncInterval

This commit is contained in:
Andras Schmelczer 2026-09-19 20:37:16 +01:00
commit c9512ab8b1

View file

@ -266,8 +266,9 @@ export class SyncSettingsTab extends PluginSettingTab {
new Notice("Checking connection to the server...");
new Notice(
(await this.syncClient.checkConnection())
.serverMessage
(
await this.syncClient.checkConnection()
).serverMessage
);
await this.statusDescription.updateConnectionState();
} 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(