From 37010a6414400230f38944bdcc5fc0ec0bbeebc2 Mon Sep 17 00:00:00 2001 From: Andreas Coroiu Date: Wed, 14 Jun 2023 14:10:39 +0200 Subject: [PATCH] [PM-2642] Fix feature flags not working properly when urls load from storage (#5598) * fix: feature flags not working properly Due to race conditions the api url is not set during the first fetch och server config. This causes the config to be fetched from `api.bitwarden.com`. The config is then supposed to be re-fetched when the api url is set by the environment service, but due to a missing line this is not done when the urls are set from storage. * feat: change to `Observable` --- .../src/platform/abstractions/environment.service.ts | 2 +- libs/common/src/platform/services/environment.service.ts | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libs/common/src/platform/abstractions/environment.service.ts b/libs/common/src/platform/abstractions/environment.service.ts index 27e4125a29d..e4d6a550014 100644 --- a/libs/common/src/platform/abstractions/environment.service.ts +++ b/libs/common/src/platform/abstractions/environment.service.ts @@ -18,7 +18,7 @@ export type PayPalConfig = { }; export abstract class EnvironmentService { - urls: Observable; + urls: Observable; hasBaseUrl: () => boolean; getNotificationsUrl: () => string; diff --git a/libs/common/src/platform/services/environment.service.ts b/libs/common/src/platform/services/environment.service.ts index 5e228cf7327..02e0fcfab23 100644 --- a/libs/common/src/platform/services/environment.service.ts +++ b/libs/common/src/platform/services/environment.service.ts @@ -8,8 +8,8 @@ import { import { StateService } from "../abstractions/state.service"; export class EnvironmentService implements EnvironmentServiceAbstraction { - private readonly urlsSubject = new Subject(); - urls: Observable = this.urlsSubject; + private readonly urlsSubject = new Subject(); + urls: Observable = this.urlsSubject.asObservable(); protected baseUrl: string; protected webVaultUrl: string; @@ -139,6 +139,8 @@ export class EnvironmentService implements EnvironmentServiceAbstraction { this.eventsUrl = envUrls.events = urls.events; this.keyConnectorUrl = urls.keyConnector; // scimUrl is not saved to storage + + this.urlsSubject.next(); } async setUrls(urls: Urls): Promise { @@ -176,7 +178,7 @@ export class EnvironmentService implements EnvironmentServiceAbstraction { this.keyConnectorUrl = urls.keyConnector; this.scimUrl = urls.scim; - this.urlsSubject.next(urls); + this.urlsSubject.next(); return urls; }