[refactor] Use ThemeType enum instead of string (#642)
This commit is contained in:
parent
6b4ed5fcce
commit
ca5b057b43
|
@ -1,6 +1,7 @@
|
||||||
import { BehaviorSubject } from "rxjs";
|
import { BehaviorSubject } from "rxjs";
|
||||||
|
|
||||||
import { KdfType } from "../enums/kdfType";
|
import { KdfType } from "../enums/kdfType";
|
||||||
|
import { ThemeType } from "../enums/themeType";
|
||||||
import { UriMatchType } from "../enums/uriMatchType";
|
import { UriMatchType } from "../enums/uriMatchType";
|
||||||
|
|
||||||
import { CipherData } from "../models/data/cipherData";
|
import { CipherData } from "../models/data/cipherData";
|
||||||
|
@ -287,8 +288,8 @@ export abstract class StateService<T extends Account = Account> {
|
||||||
setSsoOrganizationIdentifier: (value: string, options?: StorageOptions) => Promise<void>;
|
setSsoOrganizationIdentifier: (value: string, options?: StorageOptions) => Promise<void>;
|
||||||
getSsoState: (options?: StorageOptions) => Promise<string>;
|
getSsoState: (options?: StorageOptions) => Promise<string>;
|
||||||
setSsoState: (value: string, options?: StorageOptions) => Promise<void>;
|
setSsoState: (value: string, options?: StorageOptions) => Promise<void>;
|
||||||
getTheme: (options?: StorageOptions) => Promise<string>;
|
getTheme: (options?: StorageOptions) => Promise<ThemeType>;
|
||||||
setTheme: (value: string, options?: StorageOptions) => Promise<void>;
|
setTheme: (value: ThemeType, options?: StorageOptions) => Promise<void>;
|
||||||
getTwoFactorToken: (options?: StorageOptions) => Promise<string>;
|
getTwoFactorToken: (options?: StorageOptions) => Promise<string>;
|
||||||
setTwoFactorToken: (value: string, options?: StorageOptions) => Promise<void>;
|
setTwoFactorToken: (value: string, options?: StorageOptions) => Promise<void>;
|
||||||
getUserId: (options?: StorageOptions) => Promise<string>;
|
getUserId: (options?: StorageOptions) => Promise<string>;
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import { StateVersion } from "../../enums/stateVersion";
|
import { StateVersion } from "../../enums/stateVersion";
|
||||||
|
import { ThemeType } from "../../enums/themeType";
|
||||||
|
|
||||||
import { EnvironmentUrls } from "./environmentUrls";
|
import { EnvironmentUrls } from "./environmentUrls";
|
||||||
import { WindowState } from "./windowState";
|
import { WindowState } from "./windowState";
|
||||||
|
|
||||||
|
@ -11,7 +13,7 @@ export class GlobalState {
|
||||||
ssoOrganizationIdentifier?: string;
|
ssoOrganizationIdentifier?: string;
|
||||||
ssoState?: string;
|
ssoState?: string;
|
||||||
rememberedEmail?: string;
|
rememberedEmail?: string;
|
||||||
theme?: string = "light";
|
theme?: ThemeType = ThemeType.Light;
|
||||||
window?: WindowState = new WindowState();
|
window?: WindowState = new WindowState();
|
||||||
twoFactorToken?: string;
|
twoFactorToken?: string;
|
||||||
disableFavicon?: boolean;
|
disableFavicon?: boolean;
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { StorageService } from "../abstractions/storage.service";
|
||||||
import { HtmlStorageLocation } from "../enums/htmlStorageLocation";
|
import { HtmlStorageLocation } from "../enums/htmlStorageLocation";
|
||||||
import { KdfType } from "../enums/kdfType";
|
import { KdfType } from "../enums/kdfType";
|
||||||
import { StorageLocation } from "../enums/storageLocation";
|
import { StorageLocation } from "../enums/storageLocation";
|
||||||
|
import { ThemeType } from "../enums/themeType";
|
||||||
import { UriMatchType } from "../enums/uriMatchType";
|
import { UriMatchType } from "../enums/uriMatchType";
|
||||||
|
|
||||||
import { CipherView } from "../models/view/cipherView";
|
import { CipherView } from "../models/view/cipherView";
|
||||||
|
@ -1961,13 +1962,13 @@ export class StateService<TAccount extends Account = Account>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getTheme(options?: StorageOptions): Promise<string> {
|
async getTheme(options?: StorageOptions): Promise<ThemeType> {
|
||||||
return (
|
return (
|
||||||
await this.getGlobals(this.reconcileOptions(options, await this.defaultOnDiskLocalOptions()))
|
await this.getGlobals(this.reconcileOptions(options, await this.defaultOnDiskLocalOptions()))
|
||||||
)?.theme;
|
)?.theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
async setTheme(value: string, options?: StorageOptions): Promise<void> {
|
async setTheme(value: ThemeType, options?: StorageOptions): Promise<void> {
|
||||||
const globals = await this.getGlobals(
|
const globals = await this.getGlobals(
|
||||||
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())
|
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())
|
||||||
);
|
);
|
||||||
|
|
|
@ -16,6 +16,7 @@ import { SendData } from "../models/data/sendData";
|
||||||
import { HtmlStorageLocation } from "../enums/htmlStorageLocation";
|
import { HtmlStorageLocation } from "../enums/htmlStorageLocation";
|
||||||
import { KdfType } from "../enums/kdfType";
|
import { KdfType } from "../enums/kdfType";
|
||||||
import { StateVersion } from "../enums/stateVersion";
|
import { StateVersion } from "../enums/stateVersion";
|
||||||
|
import { ThemeType } from "../enums/themeType";
|
||||||
|
|
||||||
import { EnvironmentUrls } from "../models/domain/environmentUrls";
|
import { EnvironmentUrls } from "../models/domain/environmentUrls";
|
||||||
|
|
||||||
|
@ -191,7 +192,7 @@ export class StateMigrationService {
|
||||||
globals.ssoState = (await this.get<any>(v1Keys.ssoState)) ?? globals.ssoState;
|
globals.ssoState = (await this.get<any>(v1Keys.ssoState)) ?? globals.ssoState;
|
||||||
globals.rememberedEmail =
|
globals.rememberedEmail =
|
||||||
(await this.get<string>(v1Keys.rememberedEmail)) ?? globals.rememberedEmail;
|
(await this.get<string>(v1Keys.rememberedEmail)) ?? globals.rememberedEmail;
|
||||||
globals.theme = (await this.get<string>(v1Keys.theme)) ?? globals.theme;
|
globals.theme = (await this.get<ThemeType>(v1Keys.theme)) ?? globals.theme;
|
||||||
globals.vaultTimeout = (await this.get<number>(v1Keys.vaultTimeout)) ?? globals.vaultTimeout;
|
globals.vaultTimeout = (await this.get<number>(v1Keys.vaultTimeout)) ?? globals.vaultTimeout;
|
||||||
globals.vaultTimeoutAction =
|
globals.vaultTimeoutAction =
|
||||||
(await this.get<string>(v1Keys.vaultTimeoutAction)) ?? globals.vaultTimeoutAction;
|
(await this.get<string>(v1Keys.vaultTimeoutAction)) ?? globals.vaultTimeoutAction;
|
||||||
|
|
Loading…
Reference in New Issue