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

[CP Staging] Make sure that we first check the PersonalDetails we already have before creating fake optimistic personal details #20951

Merged
merged 2 commits into from
Jun 19, 2023
Merged
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
10 changes: 9 additions & 1 deletion src/libs/actions/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ Onyx.connect({
callback: (val) => (isNetworkOffline = lodashGet(val, 'isOffline', false)),
});

let allPersonalDetails;
Onyx.connect({
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
callback: (val) => {
allPersonalDetails = val || {};
},
});

const allReports = {};
let conciergeChatReportID;
const typingWatchTimers = {};
Expand Down Expand Up @@ -420,7 +428,7 @@ function openReport(reportID, participantLoginList = [], newReportObject = {}, p
const optimisticPersonalDetails = {};
_.map(participantLoginList, (login, index) => {
const accountID = newReportObject.participantAccountIDs[index];
optimisticPersonalDetails[accountID] = {
optimisticPersonalDetails[accountID] = allPersonalDetails[accountID] || {
Copy link
Contributor

@aimane-chnaif aimane-chnaif Jun 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be called before getting allPersonalDetails so just for null safety:

Suggested change
optimisticPersonalDetails[accountID] = allPersonalDetails[accountID] || {
optimisticPersonalDetails[accountID] = (allPersonalDetails && allPersonalDetails[accountID]) || {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this is needed since we already default allPersonalDetails to {} at the top of the file, if the data in that key doesn't exist

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's really true. I think this is also redundant:

(allPersonalDetails && allPersonalDetails[accountID]) || {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed

login,
accountID,
avatar: UserUtils.getDefaultAvatarURL(accountID),
Expand Down