mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 09:43:23 +00:00
[bug] Properly define stored window state (#638)
This commit is contained in:
@@ -19,6 +19,7 @@ import { GeneratedPasswordHistory } from "../models/domain/generatedPasswordHist
|
||||
import { Policy } from "../models/domain/policy";
|
||||
import { StorageOptions } from "../models/domain/storageOptions";
|
||||
import { SymmetricCryptoKey } from "../models/domain/symmetricCryptoKey";
|
||||
import { WindowState } from "../models/domain/windowState";
|
||||
|
||||
import { CipherView } from "../models/view/cipherView";
|
||||
import { CollectionView } from "../models/view/collectionView";
|
||||
@@ -299,6 +300,6 @@ export abstract class StateService<T extends Account = Account> {
|
||||
setVaultTimeoutAction: (value: string, options?: StorageOptions) => Promise<void>;
|
||||
getStateVersion: () => Promise<number>;
|
||||
setStateVersion: (value: number) => Promise<void>;
|
||||
getWindow: () => Promise<Map<string, any>>;
|
||||
setWindow: (value: Map<string, any>) => Promise<void>;
|
||||
getWindow: () => Promise<WindowState>;
|
||||
setWindow: (value: WindowState) => Promise<void>;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { StateVersion } from "../../enums/stateVersion";
|
||||
import { EnvironmentUrls } from "./environmentUrls";
|
||||
import { WindowState } from "./windowState";
|
||||
|
||||
export class GlobalState {
|
||||
enableAlwaysOnTop?: boolean;
|
||||
@@ -11,7 +12,7 @@ export class GlobalState {
|
||||
ssoState?: string;
|
||||
rememberedEmail?: string;
|
||||
theme?: string = "light";
|
||||
window?: Map<string, any> = new Map<string, any>();
|
||||
window?: WindowState = new WindowState();
|
||||
twoFactorToken?: string;
|
||||
disableFavicon?: boolean;
|
||||
biometricAwaitingAcceptance?: boolean;
|
||||
|
||||
10
common/src/models/domain/windowState.ts
Normal file
10
common/src/models/domain/windowState.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export class WindowState {
|
||||
width?: number;
|
||||
height?: number;
|
||||
isMaximized?: boolean;
|
||||
// TODO: displayBounds is an Electron.Rectangle.
|
||||
// We need to establish some kind of client-specific global state, similiar to the way we already extend a base Account.
|
||||
displayBounds: any;
|
||||
x?: number;
|
||||
y?: number;
|
||||
}
|
||||
@@ -36,6 +36,7 @@ import { BehaviorSubject } from "rxjs";
|
||||
|
||||
import { StateMigrationService } from "../abstractions/stateMigration.service";
|
||||
import { EnvironmentUrls } from "../models/domain/environmentUrls";
|
||||
import { WindowState } from "../models/domain/windowState";
|
||||
|
||||
const keys = {
|
||||
global: "global",
|
||||
@@ -2066,14 +2067,14 @@ export class StateService<TAccount extends Account = Account>
|
||||
await this.saveGlobals(globals, await this.defaultOnDiskOptions());
|
||||
}
|
||||
|
||||
async getWindow(): Promise<Map<string, any>> {
|
||||
async getWindow(): Promise<WindowState> {
|
||||
const globals = await this.getGlobals(await this.defaultOnDiskOptions());
|
||||
return globals?.window != null && Object.keys(globals.window).length > 0
|
||||
? globals.window
|
||||
: new Map<string, any>();
|
||||
: new WindowState();
|
||||
}
|
||||
|
||||
async setWindow(value: Map<string, any>, options?: StorageOptions): Promise<void> {
|
||||
async setWindow(value: WindowState, options?: StorageOptions): Promise<void> {
|
||||
const globals = await this.getGlobals(
|
||||
this.reconcileOptions(options, await this.defaultOnDiskOptions())
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user