Skip to content

Commit

Permalink
fix: accounts observable will never produce value if extension is `un…
Browse files Browse the repository at this point in the history
…defined`
  • Loading branch information
tien committed Jun 14, 2024
1 parent a9a6645 commit 400a09e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/core/src/wallets/injected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,18 @@ export default class InjectedWallet extends Wallet {
};

override readonly accounts$ = this.#extension$.pipe(
switchMap((extension) =>
extension === undefined
? []
: new Observable<InjectedPolkadotAccount[]>((subscriber) => {
switchMap(
(extension) =>
new Observable<InjectedPolkadotAccount[]>((subscriber) => {
if (extension === undefined) {
subscriber.next([]);
} else {
subscriber.next(extension.getAccounts());
subscriber.add(
extension.subscribe((accounts) => subscriber.next(accounts)),
);
}),
}
}),
),
);

Expand Down

0 comments on commit 400a09e

Please sign in to comment.