Gate settings updates

This commit is contained in:
Andras Schmelczer 2025-02-23 14:47:20 +00:00
commit abba023c20
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
2 changed files with 15 additions and 6 deletions

View file

@ -23,9 +23,15 @@ export class SyncService {
private readonly settings: Settings, private readonly settings: Settings,
private readonly logger: Logger private readonly logger: Logger
) { ) {
this.createClient(settings.getSettings()); this.createClient(settings.getSettings().remoteUri);
settings.addOnSettingsChangeHandlers(this.createClient.bind(this)); settings.addOnSettingsChangeHandlers((newSettings, oldSettings) => {
if (newSettings.remoteUri === oldSettings.remoteUri) {
return;
}
this.createClient(newSettings.remoteUri);
});
} }
private static formatError( private static formatError(
@ -281,14 +287,14 @@ export class SyncService {
return response.data; return response.data;
} }
private createClient(settings: SyncSettings): void { private createClient(remoteUri: string): void {
this.client = createClient<paths>({ this.client = createClient<paths>({
baseUrl: settings.remoteUri, baseUrl: remoteUri,
fetch: retriedFetchFactory(this.logger) fetch: retriedFetchFactory(this.logger)
}); });
this.clientWithoutRetries = createClient<paths>({ this.clientWithoutRetries = createClient<paths>({
baseUrl: settings.remoteUri baseUrl: remoteUri
}); });
} }
} }

View file

@ -37,7 +37,10 @@ export class Syncer {
concurrency: settings.getSettings().syncConcurrency concurrency: settings.getSettings().syncConcurrency
}); });
settings.addOnSettingsChangeHandlers((newSettings) => { settings.addOnSettingsChangeHandlers((newSettings, oldSettings) => {
if (newSettings.syncConcurrency === oldSettings.syncConcurrency) {
return;
}
this.syncQueue.concurrency = newSettings.syncConcurrency; this.syncQueue.concurrency = newSettings.syncConcurrency;
}); });