mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-22 11:45:59 +01:00
Add typing to localData object (#3368)
This commit is contained in:
parent
e2cb0cf11a
commit
063acfef40
@ -8,6 +8,7 @@ import { CollectionData } from "../models/data/collectionData";
|
|||||||
import { EncryptedOrganizationKeyData } from "../models/data/encryptedOrganizationKeyData";
|
import { EncryptedOrganizationKeyData } from "../models/data/encryptedOrganizationKeyData";
|
||||||
import { EventData } from "../models/data/eventData";
|
import { EventData } from "../models/data/eventData";
|
||||||
import { FolderData } from "../models/data/folderData";
|
import { FolderData } from "../models/data/folderData";
|
||||||
|
import { LocalData } from "../models/data/localData";
|
||||||
import { OrganizationData } from "../models/data/organizationData";
|
import { OrganizationData } from "../models/data/organizationData";
|
||||||
import { PolicyData } from "../models/data/policyData";
|
import { PolicyData } from "../models/data/policyData";
|
||||||
import { ProviderData } from "../models/data/providerData";
|
import { ProviderData } from "../models/data/providerData";
|
||||||
@ -245,8 +246,11 @@ export abstract class StateService<T extends Account = Account> {
|
|||||||
setLastActive: (value: number, options?: StorageOptions) => Promise<void>;
|
setLastActive: (value: number, options?: StorageOptions) => Promise<void>;
|
||||||
getLastSync: (options?: StorageOptions) => Promise<string>;
|
getLastSync: (options?: StorageOptions) => Promise<string>;
|
||||||
setLastSync: (value: string, options?: StorageOptions) => Promise<void>;
|
setLastSync: (value: string, options?: StorageOptions) => Promise<void>;
|
||||||
getLocalData: (options?: StorageOptions) => Promise<any>;
|
getLocalData: (options?: StorageOptions) => Promise<{ [cipherId: string]: LocalData }>;
|
||||||
setLocalData: (value: string, options?: StorageOptions) => Promise<void>;
|
setLocalData: (
|
||||||
|
value: { [cipherId: string]: LocalData },
|
||||||
|
options?: StorageOptions
|
||||||
|
) => Promise<void>;
|
||||||
getLocale: (options?: StorageOptions) => Promise<string>;
|
getLocale: (options?: StorageOptions) => Promise<string>;
|
||||||
setLocale: (value: string, options?: StorageOptions) => Promise<void>;
|
setLocale: (value: string, options?: StorageOptions) => Promise<void>;
|
||||||
getMainWindowSize: (options?: StorageOptions) => Promise<number>;
|
getMainWindowSize: (options?: StorageOptions) => Promise<number>;
|
||||||
|
4
libs/common/src/models/data/localData.ts
Normal file
4
libs/common/src/models/data/localData.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
export type LocalData = {
|
||||||
|
lastUsedDate?: number;
|
||||||
|
lastLaunched?: number;
|
||||||
|
};
|
@ -1,6 +1,7 @@
|
|||||||
import { CipherRepromptType } from "../../enums/cipherRepromptType";
|
import { CipherRepromptType } from "../../enums/cipherRepromptType";
|
||||||
import { CipherType } from "../../enums/cipherType";
|
import { CipherType } from "../../enums/cipherType";
|
||||||
import { CipherData } from "../data/cipherData";
|
import { CipherData } from "../data/cipherData";
|
||||||
|
import { LocalData } from "../data/localData";
|
||||||
import { CipherView } from "../view/cipherView";
|
import { CipherView } from "../view/cipherView";
|
||||||
|
|
||||||
import { Attachment } from "./attachment";
|
import { Attachment } from "./attachment";
|
||||||
@ -26,7 +27,7 @@ export class Cipher extends Domain {
|
|||||||
edit: boolean;
|
edit: boolean;
|
||||||
viewPassword: boolean;
|
viewPassword: boolean;
|
||||||
revisionDate: Date;
|
revisionDate: Date;
|
||||||
localData: any;
|
localData: LocalData;
|
||||||
login: Login;
|
login: Login;
|
||||||
identity: Identity;
|
identity: Identity;
|
||||||
card: Card;
|
card: Card;
|
||||||
@ -38,7 +39,7 @@ export class Cipher extends Domain {
|
|||||||
deletedDate: Date;
|
deletedDate: Date;
|
||||||
reprompt: CipherRepromptType;
|
reprompt: CipherRepromptType;
|
||||||
|
|
||||||
constructor(obj?: CipherData, localData: any = null) {
|
constructor(obj?: CipherData, localData: LocalData = null) {
|
||||||
super();
|
super();
|
||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -3,6 +3,7 @@ import { Jsonify } from "type-fest";
|
|||||||
import { CipherRepromptType } from "../../enums/cipherRepromptType";
|
import { CipherRepromptType } from "../../enums/cipherRepromptType";
|
||||||
import { CipherType } from "../../enums/cipherType";
|
import { CipherType } from "../../enums/cipherType";
|
||||||
import { LinkedIdType } from "../../enums/linkedIdType";
|
import { LinkedIdType } from "../../enums/linkedIdType";
|
||||||
|
import { LocalData } from "../data/localData";
|
||||||
import { Cipher } from "../domain/cipher";
|
import { Cipher } from "../domain/cipher";
|
||||||
|
|
||||||
import { AttachmentView } from "./attachmentView";
|
import { AttachmentView } from "./attachmentView";
|
||||||
@ -25,7 +26,7 @@ export class CipherView implements View {
|
|||||||
organizationUseTotp = false;
|
organizationUseTotp = false;
|
||||||
edit = false;
|
edit = false;
|
||||||
viewPassword = true;
|
viewPassword = true;
|
||||||
localData: any;
|
localData: LocalData;
|
||||||
login = new LoginView();
|
login = new LoginView();
|
||||||
identity = new IdentityView();
|
identity = new IdentityView();
|
||||||
card = new CardView();
|
card = new CardView();
|
||||||
|
@ -16,6 +16,7 @@ import { CollectionData } from "../models/data/collectionData";
|
|||||||
import { EncryptedOrganizationKeyData } from "../models/data/encryptedOrganizationKeyData";
|
import { EncryptedOrganizationKeyData } from "../models/data/encryptedOrganizationKeyData";
|
||||||
import { EventData } from "../models/data/eventData";
|
import { EventData } from "../models/data/eventData";
|
||||||
import { FolderData } from "../models/data/folderData";
|
import { FolderData } from "../models/data/folderData";
|
||||||
|
import { LocalData } from "../models/data/localData";
|
||||||
import { OrganizationData } from "../models/data/organizationData";
|
import { OrganizationData } from "../models/data/organizationData";
|
||||||
import { PolicyData } from "../models/data/policyData";
|
import { PolicyData } from "../models/data/policyData";
|
||||||
import { ProviderData } from "../models/data/providerData";
|
import { ProviderData } from "../models/data/providerData";
|
||||||
@ -1747,12 +1748,16 @@ export class StateService<
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getLocalData(options?: StorageOptions): Promise<any> {
|
async getLocalData(options?: StorageOptions): Promise<{ [cipherId: string]: LocalData }> {
|
||||||
return (
|
return (
|
||||||
await this.getAccount(this.reconcileOptions(options, await this.defaultOnDiskLocalOptions()))
|
await this.getAccount(this.reconcileOptions(options, await this.defaultOnDiskLocalOptions()))
|
||||||
)?.data?.localData;
|
)?.data?.localData;
|
||||||
}
|
}
|
||||||
async setLocalData(value: string, options?: StorageOptions): Promise<void> {
|
|
||||||
|
async setLocalData(
|
||||||
|
value: { [cipherId: string]: LocalData },
|
||||||
|
options?: StorageOptions
|
||||||
|
): Promise<void> {
|
||||||
const account = await this.getAccount(
|
const account = await this.getAccount(
|
||||||
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())
|
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions())
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user