From 8029793ffbae80d400af0b1753dd314b7e7a469c Mon Sep 17 00:00:00 2001 From: "Patrik J. Braun" Date: Tue, 10 Dec 2019 15:30:29 +0100 Subject: [PATCH] improving settings fetching --- src/frontend/app/ui/settings/settings.service.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/frontend/app/ui/settings/settings.service.ts b/src/frontend/app/ui/settings/settings.service.ts index 6d6dca29..c32c2e20 100644 --- a/src/frontend/app/ui/settings/settings.service.ts +++ b/src/frontend/app/ui/settings/settings.service.ts @@ -9,6 +9,7 @@ import {IPrivateConfig, ServerConfig} from '../../../../common/config/private/IP @Injectable() export class SettingsService { public settings: BehaviorSubject; + private fetchingSettings = false; constructor(private _networkService: NetworkService) { this.settings = new BehaviorSubject({ @@ -127,7 +128,16 @@ export class SettingsService { } public async getSettings(): Promise { - this.settings.next(await this._networkService.getJson>('/settings')); + if (this.fetchingSettings === true) { + return; + } + this.fetchingSettings = true; + try { + this.settings.next(await this._networkService.getJson>('/settings')); + } catch (e) { + console.error(e); + } + this.fetchingSettings = false; }