Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: hide Social Login wallet button from onboard #2740

Merged
merged 4 commits into from
Nov 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading