Skip to content

Commit

Permalink
fix: navigtion to threads
Browse files Browse the repository at this point in the history
  • Loading branch information
kosmydel committed May 20, 2024
1 parent d26e893 commit baef835
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
14 changes: 11 additions & 3 deletions src/components/PromotedActionsBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type ReportPromotedAction = (report: OnyxReport) => PromotedAction;

type PromotedActionsType = {
pin: ReportPromotedAction;
message: (accountID: number) => PromotedAction;
message: (params: {accountID?: number; login?: string}) => PromotedAction;
// join: ReportPromotedAction;
// share: ReportPromotedAction;
// hold: () => PromotedAction;
Expand All @@ -32,11 +32,19 @@ const PromotedActions = {
key: 'pin',
...HeaderUtils.getPinMenuItem(report),
}),
message: (accountID) => ({
message: ({accountID, login}) => ({
key: 'message',
icon: Expensicons.CommentBubbles,
text: Localize.translateLocal('common.message'),
onSelected: () => ReportActions.navigateToAndOpenReportWithAccountIDs([accountID]),
onSelected: () => {
if (accountID) {
ReportActions.navigateToAndOpenReportWithAccountIDs([accountID]);
return;
}
if (login) {
ReportActions.navigateToAndOpenReport([login]);
}
},
}),
// join: (report) => ({
// key: 'join',
Expand Down
17 changes: 9 additions & 8 deletions src/pages/ProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ function ProfilePage({route}: ProfilePageProps) {
const {translate, formatPhoneNumber} = useLocalize();
const accountID = Number(route.params?.accountID ?? 0);
const isCurrentUser = session?.accountID === accountID;
const loginParams = route.params?.login;

const details = useMemo((): PersonalDetails | EmptyObject => {
if (personalDetails?.[accountID]) {
Expand All @@ -103,16 +104,16 @@ function ProfilePage({route}: ProfilePageProps) {
if (ValidationUtils.isValidAccountRoute(accountID)) {
return {};
}
if (!route.params.login) {
if (!loginParams) {
return {accountID: 0, avatar: ''};
}
const foundDetails = Object.values(personalDetails ?? {}).find((personalDetail) => personalDetail?.login === route.params.login?.toLowerCase());
const foundDetails = Object.values(personalDetails ?? {}).find((personalDetail) => personalDetail?.login === loginParams?.toLowerCase());
if (foundDetails) {
return foundDetails;
}
const optimisticAccountID = UserUtils.generateAccountID(route.params.login);
return {accountID: optimisticAccountID, login: route.params.login, displayName: route.params.login, avatar: UserUtils.getDefaultAvatar(optimisticAccountID)};
}, [accountID, personalDetails, route.params.login]);
const optimisticAccountID = UserUtils.generateAccountID(loginParams);
return {accountID: optimisticAccountID, login: loginParams, displayName: loginParams, avatar: UserUtils.getDefaultAvatar(optimisticAccountID)};
}, [accountID, personalDetails, loginParams]);

const displayName = PersonalDetailsUtils.getDisplayNameOrDefault(details, undefined, undefined, isCurrentUser);
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
Expand Down Expand Up @@ -169,10 +170,10 @@ function ProfilePage({route}: ProfilePageProps) {
}

if (!isCurrentUser && !SessionActions.isAnonymousUser()) {
result.push(PromotedActions.message(accountID));
result.push(PromotedActions.message({accountID, login: loginParams}));
}
return result;
}, [accountID, isCurrentUser, report]);
}, [accountID, isCurrentUser, loginParams, report]);

return (
<ScreenWrapper testID={ProfilePage.displayName}>
Expand All @@ -182,7 +183,7 @@ function ProfilePage({route}: ProfilePageProps) {
onBackButtonPress={() => Navigation.goBack(navigateBackTo)}
/>
<View style={[styles.containerWithSpaceBetween, styles.pointerEventsBoxNone]}>
{true && (
{hasMinimumDetails && (
<ScrollView>
<View style={[styles.avatarSectionWrapper, styles.pb0]}>
<PressableWithoutFocus
Expand Down

0 comments on commit baef835

Please sign in to comment.