mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-02 18:17:46 +01:00
[PM-2398] Fix firefox extension environments bug (#5514)
This commit is contained in:
parent
86471790ca
commit
b9d3b0aff7
@ -1,4 +1,5 @@
|
|||||||
import { BehaviorSubject, concatMap, from, timer } from "rxjs";
|
import { Injectable, OnDestroy } from "@angular/core";
|
||||||
|
import { BehaviorSubject, Subject, concatMap, from, takeUntil, timer } from "rxjs";
|
||||||
|
|
||||||
import { ConfigApiServiceAbstraction } from "../../abstractions/config/config-api.service.abstraction";
|
import { ConfigApiServiceAbstraction } from "../../abstractions/config/config-api.service.abstraction";
|
||||||
import { ConfigServiceAbstraction } from "../../abstractions/config/config.service.abstraction";
|
import { ConfigServiceAbstraction } from "../../abstractions/config/config.service.abstraction";
|
||||||
@ -10,9 +11,11 @@ import { AuthenticationStatus } from "../../auth/enums/authentication-status";
|
|||||||
import { FeatureFlag } from "../../enums/feature-flag.enum";
|
import { FeatureFlag } from "../../enums/feature-flag.enum";
|
||||||
import { ServerConfigData } from "../../models/data/server-config.data";
|
import { ServerConfigData } from "../../models/data/server-config.data";
|
||||||
|
|
||||||
export class ConfigService implements ConfigServiceAbstraction {
|
@Injectable()
|
||||||
|
export class ConfigService implements ConfigServiceAbstraction, OnDestroy {
|
||||||
protected _serverConfig = new BehaviorSubject<ServerConfig | null>(null);
|
protected _serverConfig = new BehaviorSubject<ServerConfig | null>(null);
|
||||||
serverConfig$ = this._serverConfig.asObservable();
|
serverConfig$ = this._serverConfig.asObservable();
|
||||||
|
private destroy$ = new Subject<void>();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private stateService: StateService,
|
private stateService: StateService,
|
||||||
@ -27,13 +30,16 @@ export class ConfigService implements ConfigServiceAbstraction {
|
|||||||
this._serverConfig.next(serverConfig);
|
this._serverConfig.next(serverConfig);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.environmentService.urls
|
this.environmentService.urls.pipe(takeUntil(this.destroy$)).subscribe(() => {
|
||||||
.pipe(concatMap(() => from(this.fetchServerConfig())))
|
this.fetchServerConfig();
|
||||||
.subscribe((serverConfig) => {
|
|
||||||
this._serverConfig.next(serverConfig);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
this.destroy$.next();
|
||||||
|
this.destroy$.complete();
|
||||||
|
}
|
||||||
|
|
||||||
async fetchServerConfig(): Promise<ServerConfig> {
|
async fetchServerConfig(): Promise<ServerConfig> {
|
||||||
try {
|
try {
|
||||||
const response = await this.configApiService.get();
|
const response = await this.configApiService.get();
|
||||||
|
Loading…
Reference in New Issue
Block a user