From da67d79d1c1ee3267ade7db862d8e0331fdd5d99 Mon Sep 17 00:00:00 2001 From: Nishan Date: Fri, 24 Nov 2023 16:52:17 +0530 Subject: [PATCH] nits --- packages/app/components/edit-profile.tsx | 111 +++++++++++------- .../header/notifications-setting-icon.tsx | 5 +- .../app/hooks/use-wallet/use-wallet.web.ts | 2 - 3 files changed, 68 insertions(+), 50 deletions(-) diff --git a/packages/app/components/edit-profile.tsx b/packages/app/components/edit-profile.tsx index 6aa22f3d4..081c8d5f2 100644 --- a/packages/app/components/edit-profile.tsx +++ b/packages/app/components/edit-profile.tsx @@ -1,4 +1,10 @@ -import React, { useEffect, useMemo, useState, useRef } from "react"; +import React, { + useEffect, + useMemo, + useState, + useRef, + useCallback, +} from "react"; import { Platform, useWindowDimensions, @@ -267,12 +273,18 @@ export const EditProfile = () => { ); const accounts = useListSocialAccounts(); - const instagramProviderId = accounts.data?.find?.( - (v) => v.provider === "instagram" - )?.provider_account_id; - const twitterProviderId = accounts.data?.find?.( - (v) => v.provider === "twitter" - )?.provider_account_id; + const [instagramProviderId, twitterProviderId] = useMemo(() => { + let data: any = []; + accounts.data?.forEach((v) => { + if (v.provider === "instagram") { + data[0] = v.provider_account_id; + } + if (v.provider === "twitter") { + data[1] = v.provider_account_id; + } + }); + return data; + }, [accounts.data]); return ( <> @@ -651,45 +663,56 @@ const ConnectButton = ({ const { trigger: disconnectInstagram, isMutating: isDisconnectingInstagram } = useDisconnectInstagram(); const Alert = useAlert(); + + const handlePress = useCallback(async () => { + if (isConnected) { + Alert.alert( + "Disconnect " + type, + "Are you sure you want to disconnect this social account?", + [ + { + text: "Cancel", + }, + { + text: "Disconnect", + style: "destructive", + onPress: async () => { + if (type === "twitter") { + await disconnectTwitter({ + providerId, + }); + } else if (type === "instagram") { + await disconnectInstagram({ + providerId, + provider: "instagram", + }); + } + }, + }, + ] + ); + } else { + try { + await trigger({ + type, + }); + } catch { + // do nothing + } + } + }, [ + Alert, + disconnectInstagram, + disconnectTwitter, + isConnected, + providerId, + trigger, + type, + ]); + return ( { - if (isConnected) { - Alert.alert( - "Disconnect " + type, - "Are you sure you want to disconnect this social account?", - [ - { - text: "Cancel", - }, - { - text: "Disconnect", - style: "destructive", - onPress: async () => { - if (type === "twitter") { - await disconnectTwitter({ - providerId, - }); - } else if (type === "instagram") { - await disconnectInstagram({ - providerId, - provider: "instagram", - }); - } - }, - }, - ] - ); - } else { - try { - await trigger({ - type, - }); - } catch { - // do nothing - } - } - }} + onPress={handlePress} disabled={ isMutating || isDisconnectingInstagram || isDisconnectingTwitter } diff --git a/packages/app/components/header/notifications-setting-icon.tsx b/packages/app/components/header/notifications-setting-icon.tsx index 20381f47a..315a07bc9 100644 --- a/packages/app/components/header/notifications-setting-icon.tsx +++ b/packages/app/components/header/notifications-setting-icon.tsx @@ -1,5 +1,3 @@ -import { Platform } from "react-native"; - import { useIsDarkMode } from "@showtime-xyz/universal.hooks"; import { Settings } from "@showtime-xyz/universal.icon"; import { PressableScale } from "@showtime-xyz/universal.pressable-scale"; @@ -8,11 +6,10 @@ import { useRouter } from "@showtime-xyz/universal.router"; export const NotificationsSettingIcon = ({ size = 24 }) => { const router = useRouter(); const isDark = useIsDarkMode(); - const tabIndex = Platform.OS === "web" ? 2 : 1; return ( { - router.push(`/settings?tab=${tabIndex}`); + router.push(`/settings?tab=1`); }} tw="h-8 w-8 items-center justify-center rounded-full" > diff --git a/packages/app/hooks/use-wallet/use-wallet.web.ts b/packages/app/hooks/use-wallet/use-wallet.web.ts index 263ea9e31..543c1b72a 100644 --- a/packages/app/hooks/use-wallet/use-wallet.web.ts +++ b/packages/app/hooks/use-wallet/use-wallet.web.ts @@ -13,7 +13,6 @@ const useWallet = (): UseWalletReturnType => { const privy = usePrivy(); const wallets = useWallets(); const latestConnectedWallet = useLatestValueRef(wallets.wallets[0]); - console.log("connected wallets ", wallets); useConnectWallet({ onSuccess: (wallet) => { console.log("wallet connect success", wallet); @@ -59,7 +58,6 @@ const useWallet = (): UseWalletReturnType => { }; }, [connected, disconnect, privy, latestConnectedWallet, wallets.wallets]); - console.log("wallet address ", result.address); return result; };