Skip to content

Commit

Permalink
Merge pull request #3218 from Emurgo/fix/YOEXT-545/on-disconnect
Browse files Browse the repository at this point in the history
fix: trigger `onDisconnect` when removing a wallet
  • Loading branch information
vsubhuman authored Jun 16, 2023
2 parents ae440eb + 0699e36 commit 145e2da
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ export default class WalletSettingsStore extends Store<StoresMap, ActionsMap> {
}
await removeWalletFromLS(request.publicDeriver)

// remove this wallet from wallet sort list
// Remove this wallet from wallet sort list
const walletType = getWalletType(request.publicDeriver)
const walletsNavigation = this.stores.profile.walletsNavigation
const newWalletsNavigation = {
Expand All @@ -285,9 +285,22 @@ export default class WalletSettingsStore extends Store<StoresMap, ActionsMap> {
[walletType]: walletsNavigation[walletType].filter(
walletId => walletId !== request.publicDeriver.publicDeriverId)
}

await this.actions.profile.updateSortedWalletList.trigger(newWalletsNavigation);

// ==================== Disconnect related dApps ====================
await this.actions.connector.getConnectorWhitelist.trigger();
const connectorWhitelist = this.stores.connector.currentConnectorWhitelist;
const connectedDapps = connectorWhitelist.filter(
dapp => dapp.publicDeriverId === request.publicDeriver.publicDeriverId
);

for (const dapp of connectedDapps) {
await this.actions.connector.removeWalletFromWhitelist.trigger({
protocol: dapp.protocol,
url: dapp.url,
});
}

await this.removeWalletRequest.execute({
publicDeriver: request.publicDeriver,
conceptualWallet: group.publicDerivers.length === 1
Expand Down

0 comments on commit 145e2da

Please sign in to comment.