From 41d14d0b2b3e6d14c3498a5ef6711b0cb156cf63 Mon Sep 17 00:00:00 2001 From: Thierry Skoda <6875849+thierryskoda@users.noreply.github.com> Date: Fri, 25 Oct 2024 12:55:15 -0400 Subject: [PATCH] rebase 2.0.8 (#1105) --- components/Chat/Chat.tsx | 6 +- components/ConversationContextMenu.tsx | 17 +-- components/ConversationFlashList.tsx | 34 +---- components/ConversationListItem.tsx | 39 ++---- components/Search/NavigationChatButton.tsx | 19 +-- screens/ConversationList.tsx | 10 +- screens/Navigation/ConversationListNav.tsx | 4 +- screens/Navigation/ConversationNav.tsx | 24 +--- .../SplitLeftStackNavigation.tsx | 80 ----------- .../SplitRightStackNavigation.tsx | 117 ----------------- .../SplitScreenNavigation.tsx | 124 ------------------ screens/Navigation/navHelpers.ts | 8 +- screens/NewConversation/NewGroupSummary.tsx | 18 +-- screens/Profile.tsx | 64 ++++----- 14 files changed, 69 insertions(+), 495 deletions(-) delete mode 100644 screens/Navigation/SplitScreenNavigation/SplitLeftStackNavigation.tsx delete mode 100644 screens/Navigation/SplitScreenNavigation/SplitRightStackNavigation.tsx delete mode 100644 screens/Navigation/SplitScreenNavigation/SplitScreenNavigation.tsx diff --git a/components/Chat/Chat.tsx b/components/Chat/Chat.tsx index 9112d8a16..d6cd3a391 100644 --- a/components/Chat/Chat.tsx +++ b/components/Chat/Chat.tsx @@ -31,7 +31,6 @@ import { } from "../../data/store/accountsStore"; import { XmtpConversationWithUpdate } from "../../data/store/chatStore"; import { useFramesStore } from "../../data/store/framesStore"; -import { useIsSplitScreen } from "../../screens/Navigation/navHelpers"; import { ReanimatedFlashList, ReanimatedFlatList, @@ -287,7 +286,6 @@ export function Chat() { const xmtpAddress = useCurrentAccount() as string; const peerSocials = usePeerSocials(); - const isSplitScreen = useIsSplitScreen(); const recommendationsData = useRecommendationsStore( useShallow((s) => conversation?.peerAddress ? s.frens[conversation.peerAddress] : undefined @@ -456,9 +454,7 @@ export function Chat() { // minIndexForVisible: 0, // autoscrollToTopThreshold: 100, // }} - estimatedListSize={ - isSplitScreen ? undefined : Dimensions.get("screen") - } + estimatedListSize={Dimensions.get("screen")} inverted keyExtractor={keyExtractor} getItemType={getItemType(framesStore)} diff --git a/components/ConversationContextMenu.tsx b/components/ConversationContextMenu.tsx index 2e5b68373..fd2619073 100644 --- a/components/ConversationContextMenu.tsx +++ b/components/ConversationContextMenu.tsx @@ -1,24 +1,23 @@ import { AnimatedBlurView } from "@components/AnimatedBlurView"; import TableView, { TableViewItemType } from "@components/TableView/TableView"; import { ConversationReadOnly } from "@screens/ConversationReadOnly"; -import { useIsSplitScreen } from "@screens/Navigation/navHelpers"; import { backgroundColor } from "@styles/colors"; import { - SIDE_MARGIN, AUXILIARY_VIEW_MIN_HEIGHT, - HOLD_ITEM_TRANSFORM_DURATION, - contextMenuStyleGuide, BACKDROP_DARK_BACKGROUND_COLOR, BACKDROP_LIGHT_BACKGROUND_COLOR, + HOLD_ITEM_TRANSFORM_DURATION, ITEM_WIDTH, + SIDE_MARGIN, + contextMenuStyleGuide, } from "@utils/contextMenu/constants"; import React, { FC, memo, useCallback, useEffect } from "react"; import { Platform, StyleSheet, + View, useColorScheme, useWindowDimensions, - View, } from "react-native"; import { Gesture, @@ -50,7 +49,6 @@ const ConversationContextMenuComponent: FC = ({ const activeValue = useSharedValue(false); const opacityValue = useSharedValue(0); const intensityValue = useSharedValue(0); - const isSplitScreen = useIsSplitScreen(); const { height, width } = useWindowDimensions(); const colorScheme = useColorScheme(); const styles = useStyles(); @@ -143,12 +141,7 @@ const ConversationContextMenuComponent: FC = ({ { - if (isSplitScreen) { - runOnJS(closeMenu)(); - } else { - // Navigate to conversation - runOnJS(onClose)(true); - } + runOnJS(onClose)(true); })} > diff --git a/components/ConversationFlashList.tsx b/components/ConversationFlashList.tsx index 86003ddd1..919e4e44e 100644 --- a/components/ConversationFlashList.tsx +++ b/components/ConversationFlashList.tsx @@ -6,9 +6,6 @@ import { ConversationListContext } from "@utils/conversationList"; import { useCallback, useEffect, useRef } from "react"; import { Platform, StyleSheet, View, useColorScheme } from "react-native"; -import { GroupConversationItem } from "./ConversationList/GroupConversationItem"; -import HiddenRequestsButton from "./ConversationList/HiddenRequestsButton"; -import ConversationListItem from "./ConversationListItem"; import { useChatStore, useCurrentAccount, @@ -17,7 +14,6 @@ import { } from "../data/store/accountsStore"; import { useSelect } from "../data/store/storeHelpers"; import { NavigationParamList } from "../screens/Navigation/Navigation"; -import { useIsSplitScreen } from "../screens/Navigation/navHelpers"; import { ConversationFlatListHiddenRequestItem, ConversationFlatListItem, @@ -25,6 +21,9 @@ import { } from "../utils/conversation"; import { getPreferredAvatar, getProfile } from "../utils/profile"; import { conversationName } from "../utils/str"; +import { GroupConversationItem } from "./ConversationList/GroupConversationItem"; +import HiddenRequestsButton from "./ConversationList/HiddenRequestsButton"; +import ConversationListItem from "./ConversationListItem"; type Props = { onScroll?: () => void; @@ -67,37 +66,10 @@ export default function ConversationFlashList({ ); const userAddress = useCurrentAccount() as string; const peersStatus = useSettingsStore((s) => s.peersStatus); - const isSplitScreen = useIsSplitScreen(); const profiles = useProfilesStore((state) => state.profiles); const listRef = useRef | undefined>(); - const previousSearchQuery = useRef(itemsForSearchQuery); - - useEffect(() => { - // In Split screen, when we click on a convo with search active - // the search clears and the selected convo may be out of screen - // so we scroll back to it - if ( - isSplitScreen && - previousSearchQuery.current && - !itemsForSearchQuery && - openedConversationTopic - ) { - const topicIndex = items.findIndex( - (c) => c.topic === openedConversationTopic - ); - if (topicIndex === -1) return; - setTimeout(() => { - listRef.current?.scrollToIndex({ - index: topicIndex, - viewPosition: 0.5, - }); - }, 10); - } - previousSearchQuery.current = itemsForSearchQuery; - }, [isSplitScreen, items, openedConversationTopic, itemsForSearchQuery]); - const keyExtractor = useCallback((item: ConversationFlatListItem) => { return item.topic; }, []); diff --git a/components/ConversationListItem.tsx b/components/ConversationListItem.tsx index bfd7cff5c..1cbeaea4a 100644 --- a/components/ConversationListItem.tsx +++ b/components/ConversationListItem.tsx @@ -49,7 +49,6 @@ import { useChatStore, useSettingsStore, } from "../data/store/accountsStore"; -import { useIsSplitScreen } from "../screens/Navigation/navHelpers"; import { saveTopicsData } from "../utils/api"; import { getMinimalDate } from "../utils/date"; import { converseEventEmitter } from "../utils/events"; @@ -103,7 +102,6 @@ const ConversationListItem = memo(function ConversationListItem({ useSelect(["setTopicsData", "setPinnedConversations"]) ); const setPeersStatus = useSettingsStore((s) => s.setPeersStatus); - const isSplitScreen = useIsSplitScreen(); const [selected, setSelected] = useState(false); const resetSelected = useCallback(() => { setSelected(false); @@ -143,7 +141,7 @@ const ConversationListItem = memo(function ConversationListItem({ }); // Take the user back to wherever the conversation was restored "to" // https://github.com/ephemeraHQ/converse-app/issues/315#issuecomment-2312903441 - navigationRef.current?.pop(isSplitScreen ? 1 : 2); + navigationRef.current?.pop(2); }, [translate("cancel")]: () => {}, }; @@ -185,11 +183,9 @@ const ConversationListItem = memo(function ConversationListItem({ if (routeParams?.frameURL) { // Sharing a frame !! navigationRef.current?.goBack(); - if (!isSplitScreen) { - await new Promise((r) => - setTimeout(r, Platform.OS === "ios" ? 300 : 20) - ); - } + + await new Promise((r) => setTimeout(r, Platform.OS === "ios" ? 300 : 20)); + // This handle the case where the conversation is already opened converseEventEmitter.emit( "setCurrentConversationInputValue", @@ -207,7 +203,6 @@ const ConversationListItem = memo(function ConversationListItem({ conversationTopic, allowGroup, navigationRef, - isSplitScreen, colorScheme, ]); @@ -517,20 +512,10 @@ const ConversationListItem = memo(function ConversationListItem({ underlayColor={clickedItemBackgroundColor(colorScheme)} delayPressIn={75} onLongPress={onLongPress} - onPressIn={() => { - if (!isSplitScreen) return; - openConversation(); - }} - onPress={() => { - if (isSplitScreen) return; - openConversation(); - setSelected(true); - }} style={{ - backgroundColor: - selected || (isSplitScreen && conversationOpened) - ? clickedItemBackgroundColor(colorScheme) - : backgroundColor(colorScheme), + backgroundColor: selected + ? clickedItemBackgroundColor(colorScheme) + : backgroundColor(colorScheme), height: 76, }} > @@ -539,14 +524,6 @@ const ConversationListItem = memo(function ConversationListItem({ ) : ( { - if (!isSplitScreen) return; - openConversation(); - }} - onPress={() => { - if (isSplitScreen) return; - openConversation(); - }} onLongPress={onLongPress} style={styles.rippleRow} rippleColor={clickedItemBackgroundColor(colorScheme)} @@ -607,7 +584,7 @@ const ConversationListItem = memo(function ConversationListItem({ toggleReadStatus(); } }} - hitSlop={{ left: isSplitScreen ? 0 : -6 }} + hitSlop={{ left: -6 }} > {rowItem} {contextMenuComponent} diff --git a/components/Search/NavigationChatButton.tsx b/components/Search/NavigationChatButton.tsx index 463807a03..8c58a132a 100644 --- a/components/Search/NavigationChatButton.tsx +++ b/components/Search/NavigationChatButton.tsx @@ -10,7 +10,6 @@ import { currentAccount, useProfilesStore, } from "../../data/store/accountsStore"; -import { useIsSplitScreen } from "../../screens/Navigation/navHelpers"; import { navigate } from "../../utils/navigation"; import { canGroupMessage } from "../../utils/xmtpRN/conversations"; import Button from "../Button/Button"; @@ -29,7 +28,6 @@ export function NavigationChatButton({ addToGroup, }: NavigationChatProps) { const styles = useStyles(); - const isSplitScreen = useIsSplitScreen(); const [loading, setLoading] = useState(false); const profile = useProfilesStore( useShallow((s) => getProfile(address, s.profiles)) @@ -41,16 +39,13 @@ export function NavigationChatButton({ const parent = navigation.getParent(); parent?.goBack(); - setTimeout( - () => { - navigate("Conversation", { - mainConversationWithPeer: address, - focus: true, - }); - }, - isSplitScreen ? 0 : 300 - ); - }, [address, isSplitScreen, navigation]); + setTimeout(() => { + navigate("Conversation", { + mainConversationWithPeer: address, + focus: true, + }); + }, 300); + }, [address, navigation]); const addToGroupIfPossible = useCallback(async () => { if (loading) return; diff --git a/screens/ConversationList.tsx b/screens/ConversationList.tsx index b36cc4a71..cbcd799b7 100644 --- a/screens/ConversationList.tsx +++ b/screens/ConversationList.tsx @@ -23,6 +23,8 @@ import NewConversationButton from "../components/ConversationList/NewConversatio import RequestsButton from "../components/ConversationList/RequestsButton"; import EphemeralAccountBanner from "../components/EphemeralAccountBanner"; import InitialLoad from "../components/InitialLoad"; +import { useHeaderSearchBar } from "./Navigation/ConversationListNav"; +import { NavigationParamList } from "./Navigation/Navigation"; import PinnedConversations from "../components/PinnedConversations/PinnedConversations"; import Recommendations from "../components/Recommendations/Recommendations"; import NoResult from "../components/Search/NoResult"; @@ -42,9 +44,6 @@ import { } from "../utils/conversation"; import { converseEventEmitter } from "../utils/events"; import { sortRequestsBySpamScore } from "../utils/xmtpRN/conversations"; -import { useHeaderSearchBar } from "./Navigation/ConversationListNav"; -import { NavigationParamList } from "./Navigation/Navigation"; -import { useIsSplitScreen } from "./Navigation/navHelpers"; type ConversationWithLastMessagePreview = XmtpConversation & { lastMessagePreview?: LastMessagePreview; @@ -97,7 +96,6 @@ function ConversationList({ navigation, route, searchBarRef }: Props) { !initialLoadDoneOnce && flatListItems.items.length <= 1; const showNoResult = flatListItems.items.length === 0 && !!searchQuery; - const isSplit = useIsSplitScreen(); const sharingMode = !!route.params?.frameURL; const requestsCount = useMemo(() => { @@ -164,10 +162,10 @@ function ConversationList({ navigation, route, searchBarRef }: Props) { useEffect(() => { // In split screen, when selecting a convo with search active, // let's clear the search - if (isSplit && openedConversationTopic) { + if (openedConversationTopic) { clearSearch(); } - }, [clearSearch, isSplit, openedConversationTopic]); + }, [clearSearch, openedConversationTopic]); const ListHeaderComponents: React.ReactElement[] = [ { // No-op @@ -147,7 +146,6 @@ export default function ConversationListNav() { const useStyles = () => { const colorScheme = useColorScheme(); - const isSplitScreen = useIsSplitScreen(); const dimensions = useWindowDimensions(); return StyleSheet.create({ rightButtonContainer: { @@ -162,7 +160,7 @@ const useStyles = () => { web: { flexDirection: "row", justifyContent: "flex-start", - width: isSplitScreen ? 400 : dimensions.width, + width: dimensions.width, marginLeft: 16, }, }), diff --git a/screens/Navigation/ConversationNav.tsx b/screens/Navigation/ConversationNav.tsx index d7581a3dd..ce9e614d4 100644 --- a/screens/Navigation/ConversationNav.tsx +++ b/screens/Navigation/ConversationNav.tsx @@ -10,14 +10,13 @@ import { } from "react-native"; import { StackAnimationTypes } from "react-native-screens"; +import Picto from "../../components/Picto/Picto"; +import Conversation from "../Conversation"; import { NativeStack, - navigationAnimation, NavigationParamList, + navigationAnimation, } from "./Navigation"; -import { useIsSplitScreen } from "./navHelpers"; -import Picto from "../../components/Picto/Picto"; -import Conversation from "../Conversation"; export type ConversationNavParams = { topic?: string; @@ -39,10 +38,6 @@ export const ConversationScreenConfig = { export default function ConversationNav( routeParams?: ConversationNavParams | undefined ) { - // If we're in split screen mode, the topic is not passed via the usual StackNavigation - // but via the DrawerNavigation that passes it back to this component via prop - // so we override the route when instantiating Conversation - const isSplitScreen = useIsSplitScreen(); const colorScheme = useColorScheme(); const navigationOptions = useCallback( ({ navigation }: { navigation: NavigationProp }) => ({ @@ -72,18 +67,7 @@ export default function ConversationNav( return ( {({ route, navigation }) => ( - + )} ); diff --git a/screens/Navigation/SplitScreenNavigation/SplitLeftStackNavigation.tsx b/screens/Navigation/SplitScreenNavigation/SplitLeftStackNavigation.tsx deleted file mode 100644 index d04cfa3d3..000000000 --- a/screens/Navigation/SplitScreenNavigation/SplitLeftStackNavigation.tsx +++ /dev/null @@ -1,80 +0,0 @@ -import { NavigationContainer } from "@react-navigation/native"; -import { createNativeStackNavigator } from "@react-navigation/native-stack"; -import { memo } from "react"; -import { Platform, useColorScheme } from "react-native"; -import { ScreenHeaderModalCloseButton } from "../../../components/Screen/ScreenHeaderModalCloseButton"; -import { useRouter } from "../../../navigation/useNavigation"; -import { converseNavigations } from "../../../utils/navigation"; -import Accounts from "../../Accounts/Accounts"; -import ConversationBlockedListNav from "../ConversationBlockedListNav"; -import ConversationListNav from "../ConversationListNav"; -import ConversationRequestsListNav from "../ConversationRequestsListNav"; -import ConverseMatchMakerNav from "../ConverseMatchMakerNav"; -import { stackGroupScreenOptions } from "../navHelpers"; - -export type NavigationParamList = { - Accounts: undefined; - Chats: undefined; - ChatsRequests: undefined; - ConverseMatchMaker: undefined; - Blocked: undefined; -}; - -export const NativeStack = createNativeStackNavigator(); - -export const navigationAnimation = Platform.OS === "ios" ? "default" : "none"; - -const SplitLeftStackNavigation = memo(function SplitLeftStackNavigation() { - const colorScheme = useColorScheme(); - const router = useRouter(); - - return ( - { - if (r) { - converseNavigations["splitLeftStack"] = r; - } - }} - onUnhandledAction={() => { - // Since we're handling multiple navigators, - // let's silence errors when the action - // is not meant for this one - }} - > - - - ( - - ), - }} - /> - {ConversationListNav()} - {ConversationRequestsListNav()} - {ConverseMatchMakerNav()} - {ConversationBlockedListNav()} - - - - ); -}); - -export default SplitLeftStackNavigation; diff --git a/screens/Navigation/SplitScreenNavigation/SplitRightStackNavigation.tsx b/screens/Navigation/SplitScreenNavigation/SplitRightStackNavigation.tsx deleted file mode 100644 index 05bca1e71..000000000 --- a/screens/Navigation/SplitScreenNavigation/SplitRightStackNavigation.tsx +++ /dev/null @@ -1,117 +0,0 @@ -import { NavigationContainer, RouteProp } from "@react-navigation/native"; -import { createNativeStackNavigator } from "@react-navigation/native-stack"; -import * as Linking from "expo-linking"; -import { Platform, useColorScheme } from "react-native"; - -import config from "../../../config"; -import { useAppStore } from "../../../data/store/appStore"; -import { converseNavigations } from "../../../utils/navigation"; -import ConversationNav, { - ConversationNavParams, - ConversationScreenConfig, -} from "../ConversationNav"; -import GroupInviteNav from "../GroupInviteNav"; -import GroupLinkNav, { - GroupLinkNavParams, - GroupLinkScreenConfig, -} from "../GroupLinkNav"; -import GroupNav, { GroupNavParams, GroupScreenConfig } from "../GroupNav"; -import NewConversationNav, { - NewConversationNavParams, - NewConversationScreenConfig, -} from "../NewConversationNav"; -import ProfileNav, { - ProfileNavParams, - ProfileScreenConfig, -} from "../ProfileNav"; -import ShareFrameNav, { ShareFrameNavParams } from "../ShareFrameNav"; -import ShareProfileNav, { ShareProfileScreenConfig } from "../ShareProfileNav"; -import TopUpNav from "../TopUpNav"; -import UserProfileNav from "../UserProfileNav"; -import WebviewPreviewNav, { - WebviewPreviewNavParams, - WebviewPreviewScreenConfig, -} from "../WebviewPreviewNav"; -import { - getConverseInitialURL, - getConverseStateFromPath, - stackGroupScreenOptions, -} from "../navHelpers"; -import { SplitScreenDrawerParams } from "./SplitScreenNavigation"; - -export type NavigationParamList = { - Conversation: ConversationNavParams; - NewConversation: NewConversationNavParams; - NewGroupSummary: undefined; - ShareProfile: undefined; - ShareFrame: ShareFrameNavParams; - TopUp: undefined; - Profile: ProfileNavParams; - Group: GroupNavParams; - GroupLink: GroupLinkNavParams; - UserProfile: undefined; - WebviewPreview: WebviewPreviewNavParams; -}; - -export const NativeStack = createNativeStackNavigator(); -const prefix = Linking.createURL("/"); -const linking = { - prefixes: [prefix, ...config.universalLinks], - config: { - initialRouteName: "Conversation", - screens: { - Conversation: ConversationScreenConfig, - NewConversation: NewConversationScreenConfig, - Profile: ProfileScreenConfig, - Group: GroupScreenConfig, - GroupLink: GroupLinkScreenConfig, - ShareProfile: ShareProfileScreenConfig, - WebviewPreview: WebviewPreviewScreenConfig, - }, - }, - getStateFromPath: getConverseStateFromPath("splitRightStack"), - getInitialURL: getConverseInitialURL, -}; - -export const navigationAnimation = Platform.OS === "ios" ? "default" : "none"; - -export default function SplitRightStackNavigation({ - route, -}: { - route: RouteProp; -}) { - const colorScheme = useColorScheme(); - const splashScreenHidden = useAppStore((s) => s.splashScreenHidden); - return ( - { - if (r) { - converseNavigations["splitRightStack"] = r; - } - }} - onUnhandledAction={() => { - // Since we're handling multiple navigators, - // let's silence errors when the action - // is not meant for this one - }} - > - - - {ConversationNav(route.params)} - {NewConversationNav()} - {ShareProfileNav()} - {ShareFrameNav()} - {WebviewPreviewNav()} - {ProfileNav()} - {GroupNav()} - {GroupLinkNav()} - {UserProfileNav()} - {GroupInviteNav()} - {TopUpNav()} - - - - ); -} diff --git a/screens/Navigation/SplitScreenNavigation/SplitScreenNavigation.tsx b/screens/Navigation/SplitScreenNavigation/SplitScreenNavigation.tsx deleted file mode 100644 index 8e89aa6ea..000000000 --- a/screens/Navigation/SplitScreenNavigation/SplitScreenNavigation.tsx +++ /dev/null @@ -1,124 +0,0 @@ -import { createDrawerNavigator } from "@react-navigation/drawer"; -import { NavigationContainer } from "@react-navigation/native"; -import { listItemSeparatorColor } from "@styles/colors"; -import * as Linking from "expo-linking"; -import { useEffect, useRef } from "react"; -import { useColorScheme } from "react-native"; - -import config from "../../../config"; -import { - getChatStore, - useCurrentAccount, -} from "../../../data/store/accountsStore"; -import { useAppStore } from "../../../data/store/appStore"; -import { useAuthStatus } from "../../../data/store/authStore"; -import { OnboardingNavigator } from "../../../navigation/OnboardingNavigator"; -import { converseNavigations } from "../../../utils/navigation"; -import { - ConversationNavParams, - ConversationScreenConfig, -} from "../ConversationNav"; -import { getConverseInitialURL, getConverseStateFromPath } from "../navHelpers"; -import SplitLeftStackNavigation from "./SplitLeftStackNavigation"; -import SplitRightStackNavigation from "./SplitRightStackNavigation"; -import { useThemeProvider } from "../../../theme/useAppTheme"; - -export type SplitScreenDrawerParams = { - Chats: undefined; - Conversation: ConversationNavParams; -}; - -const Drawer = createDrawerNavigator(); - -const prefix = Linking.createURL("/"); -const linking = { - prefixes: [prefix, ...config.universalLinks], - config: { - initialRouteName: "Conversation", - screens: { - Conversation: ConversationScreenConfig, - }, - }, - getStateFromPath: getConverseStateFromPath("splitScreen"), - getInitialURL: getConverseInitialURL, -}; - -export default function SplitScreenNavigation() { - const splashScreenHidden = useAppStore((s) => s.splashScreenHidden); - const currentAccount = useCurrentAccount(); - const accountRef = useRef(currentAccount); - const colorScheme = useColorScheme(); - const authStatus = useAuthStatus(); - - const { navigationTheme } = useThemeProvider(); - - useEffect(() => { - if (accountRef.current !== currentAccount) { - converseNavigations["splitScreen"]?.reset({ - index: 0, - routes: [ - { - name: "Conversation", - }, - ], - type: "stack", - }); - if (currentAccount) { - getChatStore(currentAccount).getState().setOpenedConversationTopic(""); - } - } - - accountRef.current = currentAccount; - }, [currentAccount]); - - if (!splashScreenHidden) { - return null; - } - - if (authStatus === "idle") { - return null; - } - - return ( - { - if (r) { - converseNavigations["splitScreen"] = r; - } - }} - onUnhandledAction={() => { - // Since we're handling multiple navigators, - // let's silence errors when the action - // is not meant for this one - }} - > - {authStatus === "signedOut" && } - - {authStatus === "signedIn" && ( - } - screenOptions={{ - headerShown: false, - drawerType: "permanent", - drawerStyle: { - width: 400, - borderRightColor: listItemSeparatorColor(colorScheme), - }, - drawerContentContainerStyle: { paddingTop: 4 }, - overlayColor: "transparent", - }} - > - - {(navigationProps) => ( - - )} - - - )} - - ); -} diff --git a/screens/Navigation/navHelpers.ts b/screens/Navigation/navHelpers.ts index fab0546a9..9db860938 100644 --- a/screens/Navigation/navHelpers.ts +++ b/screens/Navigation/navHelpers.ts @@ -5,7 +5,7 @@ import { textPrimaryColor, } from "@styles/colors"; import { converseEventEmitter } from "@utils/events"; -import { ColorSchemeName, Platform, useWindowDimensions } from "react-native"; +import { ColorSchemeName, Platform } from "react-native"; import { initialURL } from "../../components/StateHandlers/InitialStateHandler"; import config from "../../config"; @@ -183,9 +183,3 @@ export const screenListeners = navigationStates[navigationName] = e.data; }, }); - -export const useIsSplitScreen = () => { - const dimensions = useWindowDimensions(); - - return dimensions.width > config.splitScreenThreshold; -}; diff --git a/screens/NewConversation/NewGroupSummary.tsx b/screens/NewConversation/NewGroupSummary.tsx index fa60d00dc..d2e2e3ea1 100644 --- a/screens/NewConversation/NewGroupSummary.tsx +++ b/screens/NewConversation/NewGroupSummary.tsx @@ -41,7 +41,6 @@ import { getProfile, } from "../../utils/profile"; import { createGroup } from "../../utils/xmtpRN/conversations"; -import { useIsSplitScreen } from "../Navigation/navHelpers"; const getPendingGroupMembers = ( members: any[], @@ -71,7 +70,6 @@ export default function NewGroupSummary({ const styles = useStyles(); const insets = useSafeAreaInsets(); const [creatingGroup, setCreatingGroup] = useState(false); - const isSplitScreen = useIsSplitScreen(); const [permissionPolicySet, setPermissionPolicySet] = useState({ addMemberPolicy: "allow", @@ -152,15 +150,12 @@ export default function NewGroupSummary({ navigation.getParent()?.goBack(); - setTimeout( - () => { - navigate("Conversation", { - topic: groupTopic, - focus: true, - }); - }, - isSplitScreen ? 0 : 300 - ); + setTimeout(() => { + navigate("Conversation", { + topic: groupTopic, + focus: true, + }); + }, 300); } catch (e) { logger.error(e); Alert.alert("An error occurred"); @@ -170,7 +165,6 @@ export default function NewGroupSummary({ groupDescription, groupName, permissionPolicySet, - isSplitScreen, navigation, remotePhotoUrl, route.params.members, diff --git a/screens/Profile.tsx b/screens/Profile.tsx index daf1099eb..3624dab4a 100644 --- a/screens/Profile.tsx +++ b/screens/Profile.tsx @@ -84,7 +84,6 @@ import { getIPFSAssetURI } from "../utils/thirdweb"; import { refreshBalanceForAccount } from "../utils/wallet"; import { ConversationNavParams } from "./Navigation/ConversationNav"; import { NavigationParamList } from "./Navigation/Navigation"; -import { useIsSplitScreen } from "./Navigation/navHelpers"; import { consentToPeersOnProtocol } from "../utils/xmtpRN/conversations"; export default function ProfileScreen({ @@ -120,7 +119,7 @@ export default function ProfileScreen({ const { permissions: groupPermissions } = useGroupPermissions( groupTopic ?? "" ); - const isSplitScreen = useIsSplitScreen(); + const { getXmtpSigner } = useXmtpSigner(); const privySigner = usePrivySigner(); @@ -322,39 +321,35 @@ export default function ProfileScreen({ title: translate("send_a_message"), titleColor: primaryColor(colorScheme), action: () => { - setTimeout( - () => { - const isPreviouslyInNavStack = navigation - .getState() - .routes.some((route) => { - if (route.name !== "Conversation") { - return false; - } - const params = route.params as ConversationNavParams; - return ( - params?.mainConversationWithPeer === - peerAddress.toLowerCase() - ); - }); - if (isPreviouslyInNavStack) { - navigation.navigate({ - name: "Conversation", - params: { - mainConversationWithPeer: peerAddress, - focus: true, - }, - }); - } else { - navigation.dispatch( - StackActions.push("Conversation", { - mainConversationWithPeer: peerAddress, - focus: true, - }) + setTimeout(() => { + const isPreviouslyInNavStack = navigation + .getState() + .routes.some((route) => { + if (route.name !== "Conversation") { + return false; + } + const params = route.params as ConversationNavParams; + return ( + params?.mainConversationWithPeer === peerAddress.toLowerCase() ); - } - }, - isSplitScreen ? 0 : 300 - ); + }); + if (isPreviouslyInNavStack) { + navigation.navigate({ + name: "Conversation", + params: { + mainConversationWithPeer: peerAddress, + focus: true, + }, + }); + } else { + navigation.dispatch( + StackActions.push("Conversation", { + mainConversationWithPeer: peerAddress, + focus: true, + }) + ); + } + }, 300); }, leftView: Platform.OS === "android" ? ( @@ -587,7 +582,6 @@ export default function ProfileScreen({ groupPermissions?.removeAdminPolicy, setPeersStatus, navigation, - isSplitScreen, removeMember, promoteToAdmin, promoteToSuperAdmin,