mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00:00
[AC-1479][BEEEP] Refactor ConfigService to improve observable usage (#5602)
* refactor ConfigService to use observables * make environmentService.urls a ReplaySubject --------- Co-authored-by: Hinton <hinton@users.noreply.github.com>
This commit is contained in:
@@ -138,7 +138,7 @@ export class AppComponent implements OnDestroy, OnInit {
|
||||
case "syncStarted":
|
||||
break;
|
||||
case "syncCompleted":
|
||||
await this.configService.fetchServerConfig();
|
||||
this.configService.triggerServerConfigFetch();
|
||||
break;
|
||||
case "upgradeOrganization": {
|
||||
const upgradeConfirmed = await this.dialogService.openSimpleDialog({
|
||||
|
||||
@@ -135,7 +135,7 @@ export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy
|
||||
this.loading = false;
|
||||
|
||||
// Remove the remaining lines when the sm-ga-billing flag is deleted
|
||||
const smBillingEnabled = await this.configService.getFeatureFlagBool(
|
||||
const smBillingEnabled = await this.configService.getFeatureFlag<boolean>(
|
||||
FeatureFlag.SecretsManagerBilling
|
||||
);
|
||||
this.showSecretsManagerSubscribe = this.showSecretsManagerSubscribe && smBillingEnabled;
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
Output,
|
||||
ViewChild,
|
||||
} from "@angular/core";
|
||||
import { firstValueFrom } from "rxjs";
|
||||
|
||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||
@@ -79,7 +80,7 @@ export class AddCreditComponent implements OnInit {
|
||||
this.email = this.subject;
|
||||
this.ppButtonCustomField = "user_id:" + this.userId;
|
||||
}
|
||||
this.region = await this.configService.getCloudRegion();
|
||||
this.region = await firstValueFrom(this.configService.cloudRegion$);
|
||||
this.ppButtonCustomField += ",account_credit:1";
|
||||
this.ppButtonCustomField += `,region:${this.region}`;
|
||||
this.returnUrl = window.location.href;
|
||||
|
||||
@@ -169,7 +169,7 @@ export class OrganizationPlansComponent implements OnInit, OnDestroy {
|
||||
this.singleOrgPolicyAppliesToActiveUser = policyAppliesToActiveUser;
|
||||
});
|
||||
|
||||
this.showSecretsManagerSubscribe = await this.configService.getFeatureFlagBool(
|
||||
this.showSecretsManagerSubscribe = await this.configService.getFeatureFlag<boolean>(
|
||||
FeatureFlag.SecretsManagerBilling,
|
||||
false
|
||||
);
|
||||
|
||||
@@ -25,7 +25,7 @@ export class EnvironmentSelectorComponent implements OnInit {
|
||||
routeAndParams: string;
|
||||
|
||||
async ngOnInit() {
|
||||
this.euServerFlagEnabled = await this.configService.getFeatureFlagBool(
|
||||
this.euServerFlagEnabled = await this.configService.getFeatureFlag<boolean>(
|
||||
FeatureFlag.DisplayEuEnvironmentFlag
|
||||
);
|
||||
const domain = Utils.getDomain(window.location.href);
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
} from "@bitwarden/common/platform/abstractions/environment.service";
|
||||
import { I18nService as I18nServiceAbstraction } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { StateService as StateServiceAbstraction } from "@bitwarden/common/platform/abstractions/state.service";
|
||||
import { ConfigService } from "@bitwarden/common/platform/services/config/config.service";
|
||||
import { ContainerService } from "@bitwarden/common/platform/services/container.service";
|
||||
import { EventUploadService } from "@bitwarden/common/services/event/event-upload.service";
|
||||
import { VaultTimeoutService } from "@bitwarden/common/services/vault-timeout/vault-timeout.service";
|
||||
@@ -32,7 +33,8 @@ export class InitService {
|
||||
private stateService: StateServiceAbstraction,
|
||||
private cryptoService: CryptoServiceAbstraction,
|
||||
private themingService: AbstractThemingService,
|
||||
private encryptService: EncryptService
|
||||
private encryptService: EncryptService,
|
||||
private configService: ConfigService
|
||||
) {}
|
||||
|
||||
init() {
|
||||
@@ -57,6 +59,8 @@ export class InitService {
|
||||
await this.themingService.monitorThemeChanges();
|
||||
const containerService = new ContainerService(this.cryptoService, this.encryptService);
|
||||
containerService.attachToGlobal(this.win);
|
||||
|
||||
this.configService.init();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user