Skip to content

Commit 06cd839

Browse files
committed
fix: removed duplicate popup when cancel connection
1 parent 65e80da commit 06cd839

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/providers/WalletProvider.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,18 @@ export const WalletProvider = ({ children }: { children: React.ReactNode }) => {
4848
try {
4949
popupLock.current = true;
5050
wallet.setWallet(walletId);
51-
5251
const [a, n] = await Promise.all([
5352
wallet.getAddress(),
5453
wallet.getNetwork(),
5554
]);
56-
55+
if (!a.address) storage.setItem("walletId", "");
5756
if (a.address !== address) setAddress(a.address);
5857
if (n.network !== network) setNetwork(n.network);
5958
if (n.networkPassphrase !== networkPassphrase)
6059
setNetworkPassphrase(n.networkPassphrase);
6160
} catch (e) {
6261
// If `getNetwork` or `getAddress` throw errors... sign the user out???
6362
nullify();
64-
6563
// then log the error (instead of throwing) so we have visibility
6664
// into the error while working on Scaffold Stellar but we do not
6765
// crash the app process

src/util/wallet.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ export const connectWallet = async () => {
2222

2323
// Now open selected wallet's login flow by calling `getAddress` --
2424
// Yes, it's strange that a getter has a side effect of opening a modal
25-
void kit.getAddress().then(() => {
25+
void kit.getAddress().then((address) => {
2626
// Once `getAddress` returns successfully, we know they actually
2727
// connected the selected wallet, and we set our localStorage
28-
storage.setItem("walletId", selectedId);
28+
if (address.address) storage.setItem("walletId", selectedId);
29+
else storage.setItem("walletId", "");
2930
});
3031
},
3132
});

0 commit comments

Comments
 (0)