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

[TS migration] Migrate 'PersonalDetailsUtils.js' lib to TypeScript #30169

Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
894f232
[TS migration] Migrate 'PersonalDetailsUtils.js' lib to TypeScript
BartoszGrajdek Sep 21, 2023
9510a4e
Migrate personal details utils to TS
BartoszGrajdek Sep 26, 2023
12832ed
Merge changes
BartoszGrajdek Oct 23, 2023
1caa40d
Rename personal details
BartoszGrajdek Oct 23, 2023
ed764e4
[TS migration] Migrate 'PersonalDetailsUtils.js' lib to TypeScript
BartoszGrajdek Oct 23, 2023
209f33c
Tweak getDisplayNameOrDefault usages
BartoszGrajdek Oct 23, 2023
9e97b7e
Resolve merge conflicts & fixes
BartoszGrajdek Oct 24, 2023
7d00e4b
Fix: review of personalDetailsUtils.ts
BartoszGrajdek Oct 26, 2023
729e718
Resolve merge conflicts
BartoszGrajdek Oct 30, 2023
ada39cf
Fix typecheck errors PersonalDetailsUtils
BartoszGrajdek Oct 30, 2023
d0f7046
Resolve merge conflicts
BartoszGrajdek Nov 15, 2023
5e717fe
fix: typecheck errors
BartoszGrajdek Nov 15, 2023
c0ef729
fix: resolve merge conflicts
BartoszGrajdek Nov 23, 2023
9ddcc2f
fix: lint
BartoszGrajdek Nov 23, 2023
0309f32
Resolve merge conflicts
BartoszGrajdek Dec 3, 2023
df26c75
fix: merge conflicts
BartoszGrajdek Dec 7, 2023
1e4eaaf
fix: handle PersonalDetailsUtils.getDisplayNameOrDefault properly
BartoszGrajdek Dec 7, 2023
e98aece
Merge main
BartoszGrajdek Dec 15, 2023
866ef5c
change default value for owner account
BartoszGrajdek Dec 15, 2023
d63f975
Resolve merge conflict
BartoszGrajdek Dec 15, 2023
65dda0d
Fix: typecheck
BartoszGrajdek Dec 18, 2023
24f5eb2
Merge remote-tracking branch 'origin/main' into ts-migration/personal…
BartoszGrajdek Dec 18, 2023
40d8204
fix: types in util files
BartoszGrajdek Dec 18, 2023
d2dfec6
fix: unit test
BartoszGrajdek Dec 18, 2023
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
2 changes: 1 addition & 1 deletion src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ type OnyxValues = {
[ONYXKEYS.NETWORK]: OnyxTypes.Network;
[ONYXKEYS.CUSTOM_STATUS_DRAFT]: OnyxTypes.CustomStatusDraft;
[ONYXKEYS.INPUT_FOCUSED]: boolean;
[ONYXKEYS.PERSONAL_DETAILS_LIST]: Record<string, OnyxTypes.PersonalDetails>;
[ONYXKEYS.PERSONAL_DETAILS_LIST]: OnyxTypes.PersonalDetailsList;
[ONYXKEYS.PRIVATE_PERSONAL_DETAILS]: OnyxTypes.PrivatePersonalDetails;
[ONYXKEYS.TASK]: OnyxTypes.Task;
[ONYXKEYS.CURRENCY_LIST]: Record<string, OnyxTypes.Currency>;
Expand Down
6 changes: 3 additions & 3 deletions src/components/ArchivedReportFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ const defaultProps = {

function ArchivedReportFooter(props) {
const archiveReason = lodashGet(props.reportClosedAction, 'originalMessage.reason', CONST.REPORT.ARCHIVE_REASON.DEFAULT);
let displayName = PersonalDetailsUtils.getDisplayNameOrDefault(props.personalDetails, [props.report.ownerAccountID, 'displayName']);
let displayName = PersonalDetailsUtils.getDisplayNameOrDefault(lodashGet(props.personalDetails, [props.report.ownerAccountID, 'displayName']));

let oldDisplayName;
if (archiveReason === CONST.REPORT.ARCHIVE_REASON.ACCOUNT_MERGED) {
const newAccountID = props.reportClosedAction.originalMessage.newAccountID;
const oldAccountID = props.reportClosedAction.originalMessage.oldAccountID;
displayName = PersonalDetailsUtils.getDisplayNameOrDefault(props.personalDetails, [newAccountID, 'displayName']);
oldDisplayName = PersonalDetailsUtils.getDisplayNameOrDefault(props.personalDetails, [oldAccountID, 'displayName']);
displayName = PersonalDetailsUtils.getDisplayNameOrDefault(lodashGet(props.personalDetails, [newAccountID, 'displayName']));
oldDisplayName = PersonalDetailsUtils.getDisplayNameOrDefault(lodashGet(props.personalDetails, [oldAccountID, 'displayName']));
}

const shouldRenderHTML = archiveReason !== CONST.REPORT.ARCHIVE_REASON.DEFAULT;
Expand Down
6 changes: 3 additions & 3 deletions src/components/withCurrentUserPersonalDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import {OnyxEntry, withOnyx} from 'react-native-onyx';
import getComponentDisplayName from '@libs/getComponentDisplayName';
import personalDetailsPropType from '@pages/personalDetailsPropType';
import ONYXKEYS from '@src/ONYXKEYS';
import type {PersonalDetails, Session} from '@src/types/onyx';
import type {PersonalDetails, PersonalDetailsList, Session} from '@src/types/onyx';

type CurrentUserPersonalDetails = PersonalDetails | Record<string, never>;

type OnyxProps = {
/** Personal details of all the users, including current user */
personalDetails: OnyxEntry<Record<string, PersonalDetails>>;
personalDetails: OnyxEntry<PersonalDetailsList>;

/** Session of the current user */
session: OnyxEntry<Session>;
Expand Down Expand Up @@ -37,7 +37,7 @@ export default function <TProps extends ComponentProps, TRef>(
const accountID = props.session?.accountID ?? 0;
const accountPersonalDetails = props.personalDetails?.[accountID];
const currentUserPersonalDetails: CurrentUserPersonalDetails = useMemo(
() => (accountPersonalDetails ? {...accountPersonalDetails, accountID} : {}),
() => (accountPersonalDetails ? {...accountPersonalDetails, accountID} : {}) as CurrentUserPersonalDetails,
[accountPersonalDetails, accountID],
);
return (
Expand Down
2 changes: 1 addition & 1 deletion src/libs/OptionsListUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ function createOption(accountIDs, personalDetails, report, reportActions = {}, {
(lastReportActions[report.reportID] && lastReportActions[report.reportID].originalMessage && lastReportActions[report.reportID].originalMessage.reason) ||
CONST.REPORT.ARCHIVE_REASON.DEFAULT;
lastMessageText = Localize.translate(preferredLocale, `reportArchiveReasons.${archiveReason}`, {
displayName: archiveReason.displayName || PersonalDetailsUtils.getDisplayNameOrDefault(lastActorDetails, 'displayName'),
displayName: archiveReason.displayName || PersonalDetailsUtils.getDisplayNameOrDefault(lodashGet(lastActorDetails, 'displayName')),
policyName: ReportUtils.getPolicyName(report),
});
}
Expand Down
180 changes: 0 additions & 180 deletions src/libs/PersonalDetailsUtils.js

This file was deleted.

Loading
Loading