-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Labels
bugSomething isn't workingSomething isn't working
Description
When I click "app_provider_digital_asset", I expect that to be logged, instead, what is being logged was the previous selection, "operator"
My accounts changed function looks like this
const onAccountsChanged = useCallback((wallets: sdk.dappAPI.AccountsChangedEvent) => {
if (wallets.length > 0) {
const primaryWallet = wallets.find((w) => w.primary);
if (primaryWallet) {
setLoggedInUser((previous) => {
if (!previous) {
return undefined;
}
console.log(primaryWallet.partyId) // LOGGING HERE!
return {
...previous,
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
userId: primaryWallet.userId,
primaryParty: primaryWallet.partyId,
};
});
}
} else {
throw new Error('no primary party found');
}
}, []);The listener useEffect looks like this:
React.useEffect(() => {
const setupListeners = async () => {
await sdk.onAccountsChanged(onAccountsChanged);
};
setupListeners()
.then(() => {})
.catch((e) => {
console.error(e);
});
return () => {
window.canton?.removeListener('accountsChanged', onAccountsChanged);
};
}, [loggedInUser?.primaryParty, onAccountsChanged]);Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working