No rate limiting saves

This commit is contained in:
Andras Schmelczer 2026-04-26 13:13:55 +01:00
commit 3d285b0b6e
3 changed files with 15 additions and 54 deletions

View file

@ -468,39 +468,7 @@ export class SyncSettingsTab extends PluginSettingTab {
}) })
); );
new Setting(containerEl)
.setName("Minimum save interval (ms)")
.setDesc(
"The minimum time between saving settings and database to disk, in milliseconds. Lower values save more frequently but may impact performance."
)
.addText((input) =>
input
.setValue(
this.syncClient
.getSettings()
.minimumSaveIntervalMs.toString()
)
.onChange(async (value) => {
if (value === "") {
return;
}
let parsedValue = Number.parseInt(value, 10);
if (Number.isNaN(parsedValue) || parsedValue < 0) {
parsedValue =
this.syncClient.getSettings()
.minimumSaveIntervalMs;
}
if (value !== parsedValue.toString()) {
input.setValue(parsedValue.toString());
}
return this.syncClient.setSetting(
"minimumSaveIntervalMs",
parsedValue
);
})
);
} }
private setStatusDescriptionSubscription( private setStatusDescriptionSubscription(
@ -536,8 +504,7 @@ export class SyncSettingsTab extends PluginSettingTab {
const updateTitle = ( const updateTitle = (
currentValue: SyncSettings[keyof SyncSettings] currentValue: SyncSettings[keyof SyncSettings]
): void => { ): void => {
title.innerText = `${name}${ title.innerText = `${name}${currentValue !== this.syncClient.getSettings()[settingName]
currentValue !== this.syncClient.getSettings()[settingName]
? " (unsaved)" ? " (unsaved)"
: "" : ""
}`; }`;

View file

@ -14,7 +14,6 @@ export interface SyncSettings {
diffCacheSizeMB: number; diffCacheSizeMB: number;
enableTelemetry: boolean; enableTelemetry: boolean;
networkRetryIntervalMs: number; networkRetryIntervalMs: number;
minimumSaveIntervalMs: number;
} }
export const DEFAULT_SETTINGS: SyncSettings = { export const DEFAULT_SETTINGS: SyncSettings = {
@ -29,7 +28,6 @@ export const DEFAULT_SETTINGS: SyncSettings = {
diffCacheSizeMB: 4, diffCacheSizeMB: 4,
enableTelemetry: false, enableTelemetry: false,
networkRetryIntervalMs: 1000, networkRetryIntervalMs: 1000,
minimumSaveIntervalMs: 1000
}; };
export class Settings { export class Settings {

View file

@ -150,10 +150,6 @@ export class SyncClient {
} }
); );
const rateLimitedSave = rateLimit(
persistence.save,
() => settings.getSettings().minimumSaveIntervalMs
);
const syncEventQueue = new SyncEventQueue( const syncEventQueue = new SyncEventQueue(
settings, settings,
@ -161,7 +157,7 @@ export class SyncClient {
state.database, state.database,
async (data): Promise<void> => { async (data): Promise<void> => {
state = { ...state, database: data }; state = { ...state, database: data };
await rateLimitedSave(state); await persistence.save(state);
} }
); );