Skip to content
Open
Show file tree
Hide file tree
Changes from 9 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
12 changes: 6 additions & 6 deletions src/libs/ReportUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@
};

let conciergeReportIDOnyxConnect: OnyxEntry<string>;
Onyx.connect({

Check warning on line 1048 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.CONCIERGE_REPORT_ID,
callback: (value) => {
conciergeReportIDOnyxConnect = value;
Expand All @@ -1053,7 +1053,7 @@
});

const defaultAvatarBuildingIconTestID = 'SvgDefaultAvatarBuilding Icon';
Onyx.connect({

Check warning on line 1056 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.SESSION,
callback: (value) => {
// When signed out, val is undefined
Expand All @@ -1071,7 +1071,7 @@
let allPersonalDetails: OnyxEntry<PersonalDetailsList>;
let allPersonalDetailLogins: string[];
let currentUserPersonalDetails: OnyxEntry<PersonalDetails>;
Onyx.connect({

Check warning on line 1074 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (value) => {
if (deprecatedCurrentUserAccountID) {
Expand All @@ -1083,7 +1083,7 @@
});

let allReportsDraft: OnyxCollection<Report>;
Onyx.connect({

Check warning on line 1086 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_DRAFT,
waitForCollectionCallback: true,
callback: (value) => (allReportsDraft = value),
Expand All @@ -1091,7 +1091,7 @@

let allPolicies: OnyxCollection<Policy>;
let policiesArray: Policy[] = [];
Onyx.connect({

Check warning on line 1094 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -1101,7 +1101,7 @@
});

let allPolicyDrafts: OnyxCollection<Policy>;
Onyx.connect({

Check warning on line 1104 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.POLICY_DRAFTS,
waitForCollectionCallback: true,
callback: (value) => (allPolicyDrafts = value),
Expand All @@ -1109,7 +1109,7 @@

let deprecatedAllReports: OnyxCollection<Report>;
let deprecatedReportsByPolicyID: ReportByPolicyMap;
Onyx.connect({

Check warning on line 1112 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT,
waitForCollectionCallback: true,
callback: (value) => {
Expand Down Expand Up @@ -1145,14 +1145,14 @@
});

let betaConfiguration: OnyxEntry<BetaConfiguration> = {};
Onyx.connect({

Check warning on line 1148 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.BETA_CONFIGURATION,
callback: (value) => (betaConfiguration = value ?? {}),
});

let deprecatedAllTransactions: OnyxCollection<Transaction> = {};
let deprecatedReportsTransactions: Record<string, Transaction[]> = {};
Onyx.connect({

Check warning on line 1155 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.TRANSACTION,
waitForCollectionCallback: true,
callback: (value) => {
Expand All @@ -1178,7 +1178,7 @@
});

let allReportActions: OnyxCollection<ReportActions>;
Onyx.connect({

Check warning on line 1181 in src/libs/ReportUtils.ts

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Onyx.connect() is deprecated. Use useOnyx() hook instead and pass the data as parameters to a pure function
key: ONYXKEYS.COLLECTION.REPORT_ACTIONS,
waitForCollectionCallback: true,
callback: (actions) => {
Expand Down Expand Up @@ -3312,7 +3312,7 @@
const avatars: Icon[] = [];

for (const accountID of participantsList) {
const avatarSource = personalDetails?.[accountID]?.avatar ?? FallbackAvatar;
const avatarSource = personalDetails?.[accountID]?.avatar ?? getDefaultAvatarURL({accountID});
const displayNameLogin = personalDetails?.[accountID]?.displayName ? personalDetails?.[accountID]?.displayName : personalDetails?.[accountID]?.login;
const userIcon = {
id: accountID,
Expand Down Expand Up @@ -3594,7 +3594,7 @@

return {
id: accountID,
source: details?.avatar ?? FallbackAvatar,
source: details?.avatar ?? getDefaultAvatarURL({accountID}),
type: CONST.ICON_TYPE_AVATAR,
name: displayName,
fallbackIcon: details?.fallbackIcon,
Expand Down Expand Up @@ -3652,7 +3652,7 @@
const workspaceIcon = getWorkspaceIcon(report, policy);
const actorDetails = parentReportAction?.actorAccountID ? personalDetails?.[parentReportAction.actorAccountID] : undefined;
const memberIcon = {
source: actorDetails?.avatar ?? FallbackAvatar,
source: actorDetails?.avatar ?? getDefaultAvatarURL({accountID: parentReportAction?.actorAccountID}),
id: parentReportAction?.actorAccountID,
type: CONST.ICON_TYPE_AVATAR,
name: actorDetails?.displayName ?? '',
Expand All @@ -3679,7 +3679,7 @@
const actorDisplayName = getDisplayNameOrDefault(actorDetails, '', false);
const actorIcon = {
id: actorAccountID,
source: actorDetails?.avatar ?? FallbackAvatar,
source: actorDetails?.avatar ?? getDefaultAvatarURL({accountID: actorAccountID}),
name: formatPhoneNumber(actorDisplayName),
type: CONST.ICON_TYPE_AVATAR,
fallbackIcon: actorDetails?.fallbackIcon,
Expand Down Expand Up @@ -3773,15 +3773,15 @@
const managerDetails = report?.managerID ? personalDetails?.[report.managerID] : undefined;
const ownerDetails = report?.ownerAccountID ? personalDetails?.[report.ownerAccountID] : undefined;
const managerIcon = {
source: managerDetails?.avatar ?? FallbackAvatar,
source: managerDetails?.avatar ?? getDefaultAvatarURL({accountID: report?.managerID}),
id: report?.managerID,
type: CONST.ICON_TYPE_AVATAR,
name: managerDetails?.displayName ?? '',
fallbackIcon: managerDetails?.fallbackIcon,
};
const ownerIcon = {
id: report?.ownerAccountID,
source: ownerDetails?.avatar ?? FallbackAvatar,
source: ownerDetails?.avatar ?? getDefaultAvatarURL({accountID: report?.ownerAccountID}),
type: CONST.ICON_TYPE_AVATAR,
name: ownerDetails?.displayName ?? '',
fallbackIcon: ownerDetails?.fallbackIcon,
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/ReportUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1054,12 +1054,12 @@ describe('ReportUtils', () => {
const participants = getIconsForParticipants([1, 2, 3, 4, 5], participantsPersonalDetails);
expect(participants).toHaveLength(5);

expect(participants.at(3)?.source).toBeInstanceOf(Function);
expect(typeof participants.at(3)?.source).toBe('string');
expect(participants.at(3)?.name).toBe('(833) 240-3627');
expect(participants.at(3)?.id).toBe(4);
expect(participants.at(3)?.type).toBe('avatar');

expect(participants.at(1)?.source).toBeInstanceOf(Function);
expect(typeof participants.at(1)?.source).toBe('string');
expect(participants.at(1)?.name).toBe('floki@vikings.net');
expect(participants.at(1)?.id).toBe(2);
expect(participants.at(1)?.type).toBe('avatar');
Expand Down Expand Up @@ -1104,12 +1104,12 @@ describe('ReportUtils', () => {
const sortedParticipants = sortIconsByName(participants, participantsPersonalDetails, localeCompare);
expect(sortedParticipants).toHaveLength(5);

expect(sortedParticipants.at(0)?.source).toBeInstanceOf(Function);
expect(typeof sortedParticipants.at(0)?.source).toBe('string');
expect(sortedParticipants.at(0)?.name).toBe('(833) 240-3627');
expect(sortedParticipants.at(0)?.id).toBe(4);
expect(sortedParticipants.at(0)?.type).toBe('avatar');

expect(sortedParticipants.at(1)?.source).toBeInstanceOf(Function);
expect(typeof sortedParticipants.at(1)?.source).toBe('string');
expect(sortedParticipants.at(1)?.name).toBe('floki@vikings.net');
expect(sortedParticipants.at(1)?.id).toBe(2);
expect(sortedParticipants.at(1)?.type).toBe('avatar');
Expand Down
Loading