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

Reduce string unions in Route type (part 2) #55065

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 5 additions & 5 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ const ROUTES = {
},
PROFILE: {
route: 'a/:accountID',
getRoute: (accountID?: string | number, backTo?: string, login?: string) => {
const baseRoute = getUrlWithBackToParam(`a/${accountID as string}`, backTo);
getRoute: (accountID?: number, backTo?: string, login?: string) => {
const baseRoute = getUrlWithBackToParam(`a/${accountID}`, backTo);
const loginParam = login ? `?login=${encodeURIComponent(login)}` : '';
return `${baseRoute}${loginParam}` as const;
},
},
PROFILE_AVATAR: {
route: 'a/:accountID/avatar',
getRoute: (accountID: string | number) => `a/${accountID as string}/avatar` as const,
getRoute: (accountID: number) => `a/${accountID}/avatar` as const,
},

GET_ASSISTANCE: {
Expand Down Expand Up @@ -410,15 +410,15 @@ const ROUTES = {
},
PRIVATE_NOTES_EDIT: {
route: 'r/:reportID/notes/:accountID/edit',
getRoute: (reportID: string, accountID: string | number, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/notes/${accountID as string}/edit` as const, backTo),
getRoute: (reportID: string, accountID: number, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/notes/${accountID}/edit` as const, backTo),
},
ROOM_MEMBERS: {
route: 'r/:reportID/members',
getRoute: (reportID: string, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/members` as const, backTo),
},
ROOM_MEMBER_DETAILS: {
route: 'r/:reportID/members/:accountID',
getRoute: (reportID: string, accountID: string | number, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/members/${accountID as string}` as const, backTo),
getRoute: (reportID: string, accountID: number, backTo?: string) => getUrlWithBackToParam(`r/${reportID}/members/${accountID}` as const, backTo),
},
ROOM_INVITE: {
route: 'r/:reportID/invite/:role?',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
accountID = parseInt(htmlAttribAccountID, 10);
mentionDisplayText = LocalePhoneNumber.formatPhoneNumber(user?.login ?? '') || PersonalDetailsUtils.getDisplayNameOrDefault(user);
mentionDisplayText = getShortMentionIfFound(mentionDisplayText, htmlAttributeAccountID, user?.login ?? '') ?? '';
navigationRoute = ROUTES.PROFILE.getRoute(htmlAttribAccountID, Navigation.getReportRHPActiveRoute());
navigationRoute = ROUTES.PROFILE.getRoute(accountID, Navigation.getReportRHPActiveRoute());
} else if ('data' in tnodeClone && !isEmptyObject(tnodeClone.data)) {
// We need to remove the LTR unicode and leading @ from data as it is not part of the login
mentionDisplayText = tnodeClone.data.replace(CONST.UNICODE.LTR, '').slice(1);
Expand Down Expand Up @@ -91,12 +91,12 @@
if (isDisabled) {
return;
}
showContextMenuForReport(event, anchor, report?.reportID ?? '-1', action, checkIfContextMenuActive, ReportUtils.isArchivedRoom(report, reportNameValuePairs));

Check failure on line 94 in src/components/HTMLEngineProvider/HTMLRenderers/MentionUserRenderer.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

}}
onPress={(event) => {
event.preventDefault();
if (!isEmpty(htmlAttribAccountID)) {
Navigation.navigate(ROUTES.PROFILE.getRoute(htmlAttribAccountID, Navigation.getReportRHPActiveRoute()));
Navigation.navigate(ROUTES.PROFILE.getRoute(parseInt(htmlAttribAccountID, 10), Navigation.getReportRHPActiveRoute()));
return;
}
Navigation.navigate(ROUTES.PROFILE.getRoute(accountID, Navigation.getReportRHPActiveRoute(), mentionDisplayText));
Expand Down
2 changes: 1 addition & 1 deletion src/components/RoomHeaderAvatars.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function RoomHeaderAvatars({icons, reportID}: RoomHeaderAvatarsProps) {
}

if (icon.id) {
Navigation.navigate(ROUTES.PROFILE_AVATAR.getRoute(icon.id));
Navigation.navigate(ROUTES.PROFILE_AVATAR.getRoute(Number(icon.id)));
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/pages/PrivateNotes/PrivateNotesListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function PrivateNotesListPage({report, accountID: sessionAccountID}: PrivateNote
reportID: report.reportID,
accountID,
title: Number(sessionAccountID) === Number(accountID) ? translate('privateNotes.myNote') : personalDetailsList?.[accountID]?.login ?? '',
action: () => Navigation.navigate(ROUTES.PRIVATE_NOTES_EDIT.getRoute(report.reportID, accountID, backTo)),
action: () => Navigation.navigate(ROUTES.PRIVATE_NOTES_EDIT.getRoute(report.reportID, Number(accountID), backTo)),
fabioh8010 marked this conversation as resolved.
Show resolved Hide resolved
brickRoadIndicator: privateNoteBrickRoadIndicator(Number(accountID)),
note: privateNote?.note ?? '',
disabled: Number(sessionAccountID) !== Number(accountID),
Expand Down
2 changes: 1 addition & 1 deletion src/pages/ProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@
selector: (account) => account?.guideCalendarLink,
});

const accountID = Number(route.params?.accountID ?? -1);

Check failure on line 88 in src/pages/ProfilePage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

const isCurrentUser = session?.accountID === accountID;
const reportKey = useMemo(() => {
const reportID = isCurrentUser
? ReportUtils.findSelfDMReportID()
: ReportUtils.getChatByParticipants(session?.accountID ? [accountID, session.accountID] : [], reports)?.reportID ?? '-1';

Check failure on line 93 in src/pages/ProfilePage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check


if (SessionActions.isAnonymousUser() || !reportID) {
return `${ONYXKEYS.COLLECTION.REPORT}0` as const;
Expand Down Expand Up @@ -197,7 +197,7 @@
<View style={[styles.avatarSectionWrapper, styles.pb0]}>
<PressableWithoutFocus
style={[styles.noOutline, styles.mb4]}
onPress={() => Navigation.navigate(ROUTES.PROFILE_AVATAR.getRoute(String(accountID)))}
onPress={() => Navigation.navigate(ROUTES.PROFILE_AVATAR.getRoute(accountID))}
accessibilityLabel={translate('common.profile')}
accessibilityRole={CONST.ROLE.BUTTON}
disabled={!hasAvatar}
Expand Down Expand Up @@ -248,7 +248,7 @@
{translate(isSMSLogin ? 'common.phoneNumber' : 'common.email')}
</Text>
<CommunicationsLink value={phoneOrEmail ?? ''}>
<UserDetailsTooltip accountID={details?.accountID ?? -1}>

Check failure on line 251 in src/pages/ProfilePage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

<Text
numberOfLines={1}
style={styles.w100}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/home/report/ReportActionItemSingle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type ReportActionItemSingleProps = Partial<ChildrenProps> & {
isHovered?: boolean;
};

const showUserDetails = (accountID: string) => {
const showUserDetails = (accountID: number) => {
Navigation.navigate(ROUTES.PROFILE.getRoute(accountID, Navigation.getReportRHPActiveRoute()));
};

Expand Down Expand Up @@ -197,7 +197,7 @@ function ReportActionItemSingle({
Navigation.navigate(ROUTES.REPORT_PARTICIPANTS.getRoute(iouReportID, Navigation.getReportRHPActiveRoute()));
return;
}
showUserDetails(action?.delegateAccountID ? String(action.delegateAccountID) : String(actorAccountID));
showUserDetails(action?.delegateAccountID ? action.delegateAccountID : Number(actorAccountID));
fabioh8010 marked this conversation as resolved.
Show resolved Hide resolved
}
}, [isWorkspaceActor, reportID, actorAccountID, action?.delegateAccountID, iouReportID, displayAllActors]);

Expand Down
2 changes: 1 addition & 1 deletion src/pages/settings/Profile/ProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
};

const avatarURL = currentUserPersonalDetails?.avatar ?? '';
const accountID = currentUserPersonalDetails?.accountID ?? '-1';

Check failure on line 55 in src/pages/settings/Profile/ProfilePage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check


const contactMethodBrickRoadIndicator = UserUtils.getLoginListBrickRoadIndicator(loginList);
const emojiCode = currentUserPersonalDetails?.status?.emojiCode ?? '';
Expand Down Expand Up @@ -184,7 +184,7 @@
errors={currentUserPersonalDetails?.errorFields?.avatar ?? null}
errorRowStyles={styles.mt6}
onErrorClose={PersonalDetails.clearAvatarErrors}
onViewPhotoPress={() => Navigation.navigate(ROUTES.PROFILE_AVATAR.getRoute(String(accountID)))}
onViewPhotoPress={() => Navigation.navigate(ROUTES.PROFILE_AVATAR.getRoute(accountID))}
previewSource={UserUtils.getFullSizeAvatar(avatarURL, accountID)}
originalFileName={currentUserPersonalDetails.originalFileName}
headerTitle={translate('profilePage.profileAvatar')}
Expand Down
Loading