Skip to content

Commit 83ddf1f

Browse files
committed
fix: await destroySession calls so that notifyListeners is called after the mutation completes
1 parent 1e1ed25 commit 83ddf1f

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

lib/sessionManager/stores/chromeStore.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export class ChromeStore<V extends string = StorageKeys>
5353
});
5454
},
5555
);
56+
this.notifyListeners();
5657
return;
5758
}
5859
await chrome.storage.local.set({

lib/sessionManager/stores/expoSecureStore.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ export class ExpoSecureStore<
4040
*/
4141
async destroySession(): Promise<void> {
4242
const keys = Object.values(StorageKeys);
43-
keys.forEach(async (key) => {
44-
await this.removeSessionItem(key);
45-
});
43+
await Promise.all(keys.map((key) => this.removeSessionItem(key)));
4644

4745
this.notifyListeners();
4846
}

lib/sessionManager/stores/localStorage.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ export class LocalStorage<V extends string = StorageKeys>
2424
* @returns {void}
2525
*/
2626
async destroySession(): Promise<void> {
27-
this.internalItems.forEach((key) => {
28-
this.removeSessionItem(key);
29-
});
27+
await Promise.all(
28+
Array.from(this.internalItems).map((key) => this.removeSessionItem(key)),
29+
);
3030

3131
this.notifyListeners();
3232
}

0 commit comments

Comments
 (0)