From 6a64ad6cee106d23a05a366c57f0f9eb1878dd0c Mon Sep 17 00:00:00 2001 From: Marc Glasser Date: Mon, 18 Jul 2022 07:35:24 -1000 Subject: [PATCH] Get current user personal details directly in Report.js --- src/libs/actions/Report.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index ccf501905c48..fbf8a00873c9 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -50,10 +50,10 @@ Onyx.connect({ callback: val => lastViewedReportID = val ? Number(val) : null, }); -let myPersonalDetails; +let personalDetails; Onyx.connect({ key: ONYXKEYS.PERSONAL_DETAILS, - callback: val => myPersonalDetails = val[currentUserEmail], + callback: val => personalDetails = val, }); const allReports = {}; @@ -859,7 +859,7 @@ function buildOptimisticReportAction(reportID, text, file) { person: [ { style: 'strong', - text: myPersonalDetails.displayName || currentUserEmail, + text: lodashGet(personalDetails, [currentUserEmail, 'displayName'], currentUserEmail), type: 'TEXT', }, ], @@ -868,7 +868,7 @@ function buildOptimisticReportAction(reportID, text, file) { // Use the client generated ID as a optimistic action ID so we can remove it later sequenceNumber: optimisticReportActionID, clientID: optimisticReportActionID, - avatar: myPersonalDetails.avatar, + avatar: lodashGet(personalDetails, [currentUserEmail, 'avatar'], ReportUtils.getDefaultAvatar(currentUserEmail)), timestamp: moment().unix(), message: [ {