Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
weeman1337 committed Feb 22, 2023
1 parent d5bd930 commit 609886c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/stores/AccountPasswordStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ 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<typeof setTimeout>;

public setPassword(password: string): void {
this.password = password;
clearTimeout(this.passwordTimeoutId);
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;
};
}
4 changes: 2 additions & 2 deletions test/stores/AccountPasswordStore-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand All @@ -44,7 +44,7 @@ describe("AccountPasswordStore", () => {
});

it("should clear the password", () => {
expect(accountPasswordStore.getPassword()).toBeNull();
expect(accountPasswordStore.getPassword()).toBeUndefined();
});
});

Expand Down

0 comments on commit 609886c

Please sign in to comment.