mirror of
https://github.com/bitwarden/browser
synced 2025-12-10 21:33:27 +00:00
[bug] Allow for GlobalState to be extended and modified in clients (#646)
Some clients have unique global setting defaults (and unique global settings) For example: the web vault defaults to light theme, but most clients with theme support default to system theme. The current way we handle GlobalState is buried in jslib and not easily extendible in clients. To fix this, we need to treat GlobalState as a generic in the StateService and StateMigration service and allow for its extension in those methods and anywhere GlobalState is inited.
This commit is contained in:
@@ -76,7 +76,11 @@ import { PasswordRepromptService } from "./passwordReprompt.service";
|
||||
import { UnauthGuardService } from "./unauth-guard.service";
|
||||
import { ValidationService } from "./validation.service";
|
||||
|
||||
import { Account, AccountFactory } from "jslib-common/models/domain/account";
|
||||
import { Account } from "jslib-common/models/domain/account";
|
||||
import { GlobalState } from "jslib-common/models/domain/globalState";
|
||||
|
||||
import { GlobalStateFactory } from "jslib-common/factories/globalStateFactory";
|
||||
import { StateFactory } from "jslib-common/factories/stateFactory";
|
||||
|
||||
@NgModule({
|
||||
declarations: [],
|
||||
@@ -338,7 +342,7 @@ import { Account, AccountFactory } from "jslib-common/models/domain/account";
|
||||
secureStorageService,
|
||||
logService,
|
||||
stateMigrationService,
|
||||
new AccountFactory(Account)
|
||||
new StateFactory(GlobalState, Account)
|
||||
),
|
||||
deps: [
|
||||
StorageServiceAbstraction,
|
||||
@@ -349,7 +353,15 @@ import { Account, AccountFactory } from "jslib-common/models/domain/account";
|
||||
},
|
||||
{
|
||||
provide: StateMigrationServiceAbstraction,
|
||||
useClass: StateMigrationService,
|
||||
useFactory: (
|
||||
storageService: StorageServiceAbstraction,
|
||||
secureStorageService: StorageServiceAbstraction
|
||||
) =>
|
||||
new StateMigrationService(
|
||||
storageService,
|
||||
secureStorageService,
|
||||
new GlobalStateFactory(GlobalState)
|
||||
),
|
||||
deps: [StorageServiceAbstraction, "SECURE_STORAGE"],
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user