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

Deeplink user profile specific tabs issue ❓ #2052

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
15 changes: 15 additions & 0 deletions apps/mobile/src/components/DeepLinkRegistrar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@ export const handleDeepLinkNavigation = (url: string, navigation: RootStackNavig
},
});
}
} else if (splitBySlash.length === 2) {
const [maybeUsername, maybeGalleriesOrPostsOrFollowers] = splitBySlash;

/**
* /:username/galleries/
*/
if (maybeUsername && maybeGalleriesOrPostsOrFollowers) {
navigation.navigate('MainTabs', {
screen: 'HomeTab',
params: {
screen: 'Profile',
params: { username: maybeUsername, tab: 'Galleries' },
},
});
}
} else if (splitBySlash.length === 2) {
const [maybeUsername, maybeCollectionId] = splitBySlash;

Expand Down
11 changes: 10 additions & 1 deletion apps/mobile/src/components/ProfileView/ProfileView.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useNavigation } from '@react-navigation/native';
import { RouteProp, useRoute } from '@react-navigation/native';
import { useCallback, useEffect, useRef, useState } from 'react';
import { View, ViewProps } from 'react-native';
import { CollapsibleRef, Tabs } from 'react-native-collapsible-tab-view';
Expand All @@ -20,6 +21,7 @@ import { ProfileViewEditProfileButtonFragment$key } from '~/generated/ProfileVie
import { ProfileViewQueryFragment$key } from '~/generated/ProfileViewQueryFragment.graphql';
import { ProfileViewUsernameFragment$key } from '~/generated/ProfileViewUsernameFragment.graphql';
import { MainTabStackNavigatorProp } from '~/navigation/types';
import { MainTabStackNavigatorParamList } from '~/navigation/types';
import GalleryViewEmitter from '~/shared/components/GalleryViewEmitter';

import { GalleryBottomSheetModalType } from '../GalleryBottomSheet/GalleryBottomSheetModal';
Expand Down Expand Up @@ -51,7 +53,8 @@ export function ProfileView({ queryRef, shouldShowBackButton }: ProfileViewProps
queryRef
);

const [selectedRoute, setSelectedRoute] = useState('Featured');
const route = useRoute<RouteProp<MainTabStackNavigatorParamList, 'Profile'>>();
const [selectedRoute, setSelectedRoute] = useState<string>('Featured');

const Header = useCallback(() => {
return (
Expand All @@ -70,6 +73,12 @@ export function ProfileView({ queryRef, shouldShowBackButton }: ProfileViewProps
}
}, [selectedRoute]);

useEffect(() => {
if (route.params.tab) {
setSelectedRoute(route.params.tab);
}
}, [route.params.tab]);

return (
<View className="flex-1">
<GalleryViewEmitter queryRef={query} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function UserSearchResult({ userRef, keyword, onSelect }: Props) {
}

if (user.username) {
navigation.push('Profile', { username: user.username });
navigation.push('Profile', { username: user.username, tab: 'Galleries' });
}
}, [onSelect, navigation, user.dbid, user.username]);

Expand Down
7 changes: 6 additions & 1 deletion apps/mobile/src/navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@ export type RootStackNavigatorParamList = {

export type ScreenWithNftSelector = 'ProfilePicture' | 'Post' | 'Community';
export type MainTabStackNavigatorParamList = {
Profile: { username: string; hideBackButton?: boolean };
Profile: {
username: string;
hideBackButton?: boolean;
tab?: 'Featured' | 'Galleries' | 'Posts' | 'Followers';
};

NftDetail: {
tokenId: string;
collectionId: string | null;
Expand Down