Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
nits
Browse files Browse the repository at this point in the history
  • Loading branch information
intergalacticspacehighway committed Nov 24, 2023
1 parent 08f9d0a commit da67d79
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 50 deletions.
111 changes: 67 additions & 44 deletions packages/app/components/edit-profile.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import React, { useEffect, useMemo, useState, useRef } from "react";
import React, {
useEffect,
useMemo,
useState,
useRef,
useCallback,
} from "react";
import {
Platform,
useWindowDimensions,
Expand Down Expand Up @@ -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 (
<>
Expand Down Expand Up @@ -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 (
<PressableHover
onPress={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
}
}
}}
onPress={handlePress}
disabled={
isMutating || isDisconnectingInstagram || isDisconnectingTwitter
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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 (
<PressableScale
onPress={() => {
router.push(`/settings?tab=${tabIndex}`);
router.push(`/settings?tab=1`);
}}
tw="h-8 w-8 items-center justify-center rounded-full"
>
Expand Down
2 changes: 0 additions & 2 deletions packages/app/hooks/use-wallet/use-wallet.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -59,7 +58,6 @@ const useWallet = (): UseWalletReturnType => {
};
}, [connected, disconnect, privy, latestConnectedWallet, wallets.wallets]);

console.log("wallet address ", result.address);
return result;
};

Expand Down

0 comments on commit da67d79

Please sign in to comment.