Skip to content

Commit

Permalink
fix: return after resolve to avoid idb to be recreated (#617)
Browse files Browse the repository at this point in the history
* fix: return after resolve to avoid idb to be recreated

* Update changelog.html

Co-authored-by: Kyle Peacock <kylpeacock@gmail.com>
  • Loading branch information
peterpeterparker and krpeacock committed Sep 20, 2022
1 parent 58a892a commit 513f9b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 7 additions & 0 deletions docs/generated/changelog.html
Expand Up @@ -13,6 +13,13 @@ <h1>Agent-JS Changelog</h1>
<h2>Version 0.13.4</h2>
<ul>
<li>chore: auth-client expose storage constant keys</li>
<li>
bug: auth-client resolves window.open issue in login function in safari due to async
storage call
</li>
<li>
bug: auth-client storage wrapper returns after resolve to avoid idb to be recreated
</li>
</ul>
<h2>Version 0.13.3</h2>
<ul>
Expand Down
7 changes: 5 additions & 2 deletions packages/auth-client/src/storage.ts
Expand Up @@ -68,11 +68,14 @@ export class LocalStorage implements AuthClientStorage {
* @see implements {@link AuthClientStorage}
*/
export class IdbStorage implements AuthClientStorage {
// Intializes a KeyVal on first request
// Initializes a KeyVal on first request
private initializedDb: IdbKeyVal | undefined;
get _db(): Promise<IdbKeyVal> {
return new Promise(resolve => {
if (this.initializedDb) resolve(this.initializedDb);
if (this.initializedDb) {
resolve(this.initializedDb);
return;
}
IdbKeyVal.create({ version: DB_VERSION }).then(db => {
this.initializedDb = db;
resolve(db);
Expand Down

0 comments on commit 513f9b3

Please sign in to comment.