Skip to content

Commit

Permalink
Fix: hide Social Login wallet button from onboard (#2740)
Browse files Browse the repository at this point in the history
* Fix: hide Social Login wallet button from onboard

* Watch onboard modal

* Move to useSocialWallet
  • Loading branch information
katspaugh authored Nov 3, 2023
1 parent 13618c3 commit 3d118f3
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/hooks/wallets/mpc/useSocialWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,23 @@ import useMpc from './useMPC'

const { getStore, setStore, useStore } = new ExternalStore<ISocialWalletService>()

// Listen to onboard modal open and hide the social login button
const hideOnboardButton = () => {
const onboardRoot = document.querySelector('onboard-v2')?.shadowRoot
if (!onboardRoot) return

const hideSocialLoginButton = () => {
const walletButtons = onboardRoot.querySelectorAll('.wallet-button-container') || []
const socialButton = Array.from(walletButtons).find((el) => el.textContent?.includes(ONBOARD_MPC_MODULE_LABEL))
socialButton?.remove()
}

const observer = new MutationObserver(hideSocialLoginButton)
observer.observe(onboardRoot, { childList: true })

return () => observer.disconnect()
}

export const useInitSocialWallet = () => {
const mpcCoreKit = useMpc()
const onboard = useOnboard()
Expand Down Expand Up @@ -54,6 +71,13 @@ export const useInitSocialWallet = () => {
setStore(new SocialWalletService(mpcCoreKit))
}
}, [mpcCoreKit])

// Hide social login when onboard pops up
// @FIXME the button should work but atm it doesn't
useEffect(() => {
if (!onboard) return
return hideOnboardButton()
}, [onboard])
}

export const getSocialWalletService = getStore
Expand Down

0 comments on commit 3d118f3

Please sign in to comment.