diff --git a/src/stores/AccountPasswordStore.ts b/src/stores/AccountPasswordStore.ts index 051f58b7aa1..7b7b5a85e98 100644 --- a/src/stores/AccountPasswordStore.ts +++ b/src/stores/AccountPasswordStore.ts @@ -22,8 +22,8 @@ const PASSWORD_TIMEOUT = 5 * 60 * 1000; // five minutes * to avoid requestin the password all the time for instance during e2ee setup. */ export class AccountPasswordStore { - private password: string = null; - private passwordTimeoutId: number = null; + private password?: string; + private passwordTimeoutId?: ReturnType; public setPassword(password: string): void { this.password = password; @@ -31,13 +31,13 @@ export class AccountPasswordStore { this.passwordTimeoutId = setTimeout(this.clearPassword, PASSWORD_TIMEOUT); } - public getPassword(): string | null { + public getPassword(): string | undefined { return this.password; } public clearPassword = (): void => { clearTimeout(this.passwordTimeoutId); - this.passwordTimeoutId = null; - this.password = null; + this.passwordTimeoutId = undefined; + this.password = undefined; }; } diff --git a/test/stores/AccountPasswordStore-test.ts b/test/stores/AccountPasswordStore-test.ts index 86b83693251..f54886fd1b9 100644 --- a/test/stores/AccountPasswordStore-test.ts +++ b/test/stores/AccountPasswordStore-test.ts @@ -26,7 +26,7 @@ describe("AccountPasswordStore", () => { }); it("should not have a password by default", () => { - expect(accountPasswordStore.getPassword()).toBeNull(); + expect(accountPasswordStore.getPassword()).toBeUndefined(); }); describe("when setting a password", () => { @@ -44,7 +44,7 @@ describe("AccountPasswordStore", () => { }); it("should clear the password", () => { - expect(accountPasswordStore.getPassword()).toBeNull(); + expect(accountPasswordStore.getPassword()).toBeUndefined(); }); }); diff --git a/test/stores/SetupEncryptionStore-test.ts b/test/stores/SetupEncryptionStore-test.ts index 4693176e589..f2e27948f24 100644 --- a/test/stores/SetupEncryptionStore-test.ts +++ b/test/stores/SetupEncryptionStore-test.ts @@ -46,9 +46,9 @@ describe("SetupEncryptionStore", () => { const makeRequest = jest.fn(); client.hasSecretStorageKey.mockResolvedValue(true); client.bootstrapCrossSigning.mockImplementation(async (opts: IBootstrapCrossSigningOpts) => { - await opts.authUploadDeviceSigningKeys(makeRequest); + await opts?.authUploadDeviceSigningKeys(makeRequest); }); - mocked(accessSecretStorage).mockImplementation(async (func) => { + mocked(accessSecretStorage).mockImplementation(async (func: () => Promise) => { await func(); });