Skip to content

Commit

Permalink
Revert #960 (#1012)
Browse files Browse the repository at this point in the history
* Revert "add changeset"

This reverts commit aea46eb.

* Revert "Allow Disconnect of MWA  (#960)"

This reverts commit d8632b4.
  • Loading branch information
jordaaash authored Aug 24, 2024
1 parent aea46eb commit 3761cd8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
5 changes: 0 additions & 5 deletions .changeset/large-seas-play.md

This file was deleted.

17 changes: 9 additions & 8 deletions packages/core/react/src/WalletProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,13 @@ export function WalletProvider({
}
return [mobileWalletAdapter, ...adaptersWithStandardAdapters];
}, [adaptersWithStandardAdapters, mobileWalletAdapter]);
const [walletName, setWalletName] = useLocalStorage<WalletName | null>(localStorageKey, null);
const [walletName, setWalletName] = useLocalStorage<WalletName | null>(
localStorageKey,
getIsMobile(adaptersWithStandardAdapters) ? SolanaMobileWalletAdapterWalletName : null
);
const adapter = useMemo(
() =>
adaptersWithMobileWalletAdapter.find((a) => a.name === walletName) ??
(adaptersWithMobileWalletAdapter.length === 1 && adaptersWithMobileWalletAdapter[0] === mobileWalletAdapter
? mobileWalletAdapter
: null),
[adaptersWithMobileWalletAdapter, walletName, mobileWalletAdapter]
() => adaptersWithMobileWalletAdapter.find((a) => a.name === walletName) ?? null,
[adaptersWithMobileWalletAdapter, walletName]
);
const changeWallet = useCallback(
(nextWalletName: WalletName<string> | null) => {
Expand All @@ -106,6 +105,8 @@ export function WalletProvider({
if (!adapter) return;
function handleDisconnect() {
if (isUnloadingRef.current) return;
// Leave the adapter selected in the event of a disconnection.
if (walletName === SolanaMobileWalletAdapterWalletName && getIsMobile(adaptersWithStandardAdapters)) return;
setWalletName(null);
}
adapter.on('disconnect', handleDisconnect);
Expand Down Expand Up @@ -149,7 +150,7 @@ export function WalletProvider({
};
}, [adaptersWithStandardAdapters, walletName]);
const handleConnectError = useCallback(() => {
if (adapter) {
if (adapter && adapter.name !== SolanaMobileWalletAdapterWalletName) {
// If any error happens while connecting, unset the adapter.
changeWallet(null);
}
Expand Down

0 comments on commit 3761cd8

Please sign in to comment.