Skip to content

Commit 3761cd8

Browse files
authored
* Revert "add changeset" This reverts commit aea46eb. * Revert "Allow Disconnect of MWA (anza-xyz#960)" This reverts commit d8632b4.
1 parent aea46eb commit 3761cd8

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

.changeset/large-seas-play.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/core/react/src/WalletProvider.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,13 @@ export function WalletProvider({
7676
}
7777
return [mobileWalletAdapter, ...adaptersWithStandardAdapters];
7878
}, [adaptersWithStandardAdapters, mobileWalletAdapter]);
79-
const [walletName, setWalletName] = useLocalStorage<WalletName | null>(localStorageKey, null);
79+
const [walletName, setWalletName] = useLocalStorage<WalletName | null>(
80+
localStorageKey,
81+
getIsMobile(adaptersWithStandardAdapters) ? SolanaMobileWalletAdapterWalletName : null
82+
);
8083
const adapter = useMemo(
81-
() =>
82-
adaptersWithMobileWalletAdapter.find((a) => a.name === walletName) ??
83-
(adaptersWithMobileWalletAdapter.length === 1 && adaptersWithMobileWalletAdapter[0] === mobileWalletAdapter
84-
? mobileWalletAdapter
85-
: null),
86-
[adaptersWithMobileWalletAdapter, walletName, mobileWalletAdapter]
84+
() => adaptersWithMobileWalletAdapter.find((a) => a.name === walletName) ?? null,
85+
[adaptersWithMobileWalletAdapter, walletName]
8786
);
8887
const changeWallet = useCallback(
8988
(nextWalletName: WalletName<string> | null) => {
@@ -106,6 +105,8 @@ export function WalletProvider({
106105
if (!adapter) return;
107106
function handleDisconnect() {
108107
if (isUnloadingRef.current) return;
108+
// Leave the adapter selected in the event of a disconnection.
109+
if (walletName === SolanaMobileWalletAdapterWalletName && getIsMobile(adaptersWithStandardAdapters)) return;
109110
setWalletName(null);
110111
}
111112
adapter.on('disconnect', handleDisconnect);
@@ -149,7 +150,7 @@ export function WalletProvider({
149150
};
150151
}, [adaptersWithStandardAdapters, walletName]);
151152
const handleConnectError = useCallback(() => {
152-
if (adapter) {
153+
if (adapter && adapter.name !== SolanaMobileWalletAdapterWalletName) {
153154
// If any error happens while connecting, unset the adapter.
154155
changeWallet(null);
155156
}

0 commit comments

Comments
 (0)