Gate settings updates

This commit is contained in:
Andras Schmelczer 2025-02-23 14:47:20 +00:00
parent cb3ffde342
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 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(
@ -281,14 +287,14 @@ export class SyncService {
return response.data;
}
private createClient(settings: SyncSettings): void {
private createClient(remoteUri: string): void {
this.client = createClient<paths>({
baseUrl: settings.remoteUri,
baseUrl: remoteUri,
fetch: retriedFetchFactory(this.logger)
});
this.clientWithoutRetries = createClient<paths>({
baseUrl: settings.remoteUri
baseUrl: remoteUri
});
}
}

View file

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