Skip to content

Commit

Permalink
feat: maintain subscription when opening dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
0xKheops committed Dec 7, 2023
1 parent 9ec5200 commit c57c4b9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion apps/extension/src/core/domains/balances/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,13 @@ export class BalanceStore {
port.onDisconnect.addListener((): void => {
unsubscribe(id)
subscription.unsubscribe()
if (!this.#subscribers.observed) this.closeSubscriptions()

setTimeout(() => {
// wait 5 seconds to prevent subscription restart for these use cases :
// - popup loses focus and user reopens it right away
// - user opens popup and opens dashboard from it, which closes the popup
if (!this.#subscribers.observed) this.closeSubscriptions()
}, 5_000)
})

return true
Expand All @@ -407,6 +413,7 @@ export class BalanceStore {
if (this.#subscriptionsState !== "Closed") return
this.setSubscriptionsState("Open")
log.log("Opening balance subscriptions")
console.log("opening balances sub")

const subscriptionId = createSubscriptionId()

Expand Down

0 comments on commit c57c4b9

Please sign in to comment.