mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 23:33:31 +00:00
Add Settings service to synced services
Co-Authored-By: Daniel James Smith <djsmith85@users.noreply.github.com>
This commit is contained in:
@@ -66,7 +66,6 @@ import { PolicyApiService } from "@bitwarden/common/services/policy/policy-api.s
|
||||
import { ProviderService } from "@bitwarden/common/services/provider.service";
|
||||
import { SearchService } from "@bitwarden/common/services/search.service";
|
||||
import { SendService } from "@bitwarden/common/services/send.service";
|
||||
import { SettingsService } from "@bitwarden/common/services/settings.service";
|
||||
import { StateMigrationService } from "@bitwarden/common/services/stateMigration.service";
|
||||
import { SyncService } from "@bitwarden/common/services/sync/sync.service";
|
||||
import { SyncNotifierService } from "@bitwarden/common/services/sync/syncNotifier.service";
|
||||
@@ -93,6 +92,7 @@ import { BrowserEnvironmentService } from "../services/browser-environment.servi
|
||||
import { BrowserFolderService } from "../services/browser-folder.service";
|
||||
import { BrowserOrganizationService } from "../services/browser-organization.service";
|
||||
import { BrowserPolicyService } from "../services/browser-policy.service";
|
||||
import { BrowserSettingsService } from "../services/browser-settings.service";
|
||||
import { BrowserStateService } from "../services/browser-state.service";
|
||||
import { BrowserCryptoService } from "../services/browserCrypto.service";
|
||||
import BrowserLocalStorageService from "../services/browserLocalStorage.service";
|
||||
@@ -282,7 +282,7 @@ export default class MainBackground {
|
||||
this.appIdService,
|
||||
(expired: boolean) => this.logout(expired)
|
||||
);
|
||||
this.settingsService = new SettingsService(this.stateService);
|
||||
this.settingsService = new BrowserSettingsService(this.stateService);
|
||||
this.fileUploadService = new FileUploadService(this.logService, this.apiService);
|
||||
this.cipherService = new CipherService(
|
||||
this.cryptoService,
|
||||
|
||||
@@ -67,6 +67,7 @@ import { BrowserStateService as StateServiceAbstraction } from "../../services/a
|
||||
import { BrowserEnvironmentService } from "../../services/browser-environment.service";
|
||||
import { BrowserOrganizationService } from "../../services/browser-organization.service";
|
||||
import { BrowserPolicyService } from "../../services/browser-policy.service";
|
||||
import { BrowserSettingsService } from "../../services/browser-settings.service";
|
||||
import { BrowserStateService } from "../../services/browser-state.service";
|
||||
import { BrowserFileDownloadService } from "../../services/browserFileDownloadService";
|
||||
import BrowserMessagingService from "../../services/browserMessaging.service";
|
||||
@@ -228,8 +229,10 @@ function getBgService<T>(service: keyof MainBackground) {
|
||||
{ provide: SyncService, useFactory: getBgService<SyncService>("syncService"), deps: [] },
|
||||
{
|
||||
provide: SettingsService,
|
||||
useFactory: getBgService<SettingsService>("settingsService"),
|
||||
deps: [],
|
||||
useFactory: (stateService: StateService) => {
|
||||
return new BrowserSettingsService(stateService);
|
||||
},
|
||||
deps: [StateService],
|
||||
},
|
||||
{
|
||||
provide: AbstractStorageService,
|
||||
|
||||
11
apps/browser/src/services/browser-settings.service.ts
Normal file
11
apps/browser/src/services/browser-settings.service.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { BehaviorSubject } from "rxjs";
|
||||
|
||||
import { AccountSettingsSettings } from "@bitwarden/common/models/domain/account";
|
||||
import { SettingsService } from "@bitwarden/common/services/settings.service";
|
||||
|
||||
import { sessionSync } from "../decorators/session-sync-observable";
|
||||
|
||||
export class BrowserSettingsService extends SettingsService {
|
||||
@sessionSync({ initializer: (obj: string[][]) => obj })
|
||||
protected _settings: BehaviorSubject<AccountSettingsSettings>;
|
||||
}
|
||||
@@ -251,7 +251,7 @@ export class AccountSettings {
|
||||
}
|
||||
|
||||
export type AccountSettingsSettings = {
|
||||
equivalentDomains?: { [id: string]: any };
|
||||
equivalentDomains?: string[][];
|
||||
};
|
||||
|
||||
export class AccountTokens {
|
||||
|
||||
@@ -412,7 +412,7 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
: firstValueFrom(this.settingsService.settings$).then(
|
||||
(settings: AccountSettingsSettings) => {
|
||||
let matches: any[] = [];
|
||||
settings.equivalentDomains?.forEach((eqDomain: any) => {
|
||||
settings?.equivalentDomains?.forEach((eqDomain: any) => {
|
||||
if (eqDomain.length && eqDomain.indexOf(domain) >= 0) {
|
||||
matches = matches.concat(eqDomain);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Utils } from "../misc/utils";
|
||||
import { AccountSettingsSettings } from "../models/domain/account";
|
||||
|
||||
export class SettingsService implements SettingsServiceAbstraction {
|
||||
private _settings: BehaviorSubject<AccountSettingsSettings> = new BehaviorSubject({});
|
||||
protected _settings: BehaviorSubject<AccountSettingsSettings> = new BehaviorSubject({});
|
||||
|
||||
settings$ = this._settings.asObservable();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user