-
Notifications
You must be signed in to change notification settings - Fork 3k
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
check if report.icons and report.icons[0] exists #5381
Conversation
src/libs/OptionsListUtils.js
Outdated
@@ -230,10 +230,11 @@ function createOption(personalDetailList, report, draftComments, { | |||
? lastMessageText | |||
: Str.removeSMSDomain(personalDetail.login); | |||
} | |||
const icons = (report && report.icons && report.icons[0]) ? report.icons : [personalDetail.avatar]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please use Lodash.get
instead for this? I think it would make this more simple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
Update: use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that looks great. Thanks!
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
Details
Context: #5232
Sometimes the avatars disappear from the LHN and I was only able to reproduce the issue after logging out and loging in again with a different account.
I found out the value of
report.actions
sometimes isundefined
or has an array with an empty string (['']
). This is because the links of the avatar thumbnails are fetched after inserting thesimplifiedReports
into Onyx:here ^
PersonalDetails.getFromReportParticipants(Object.values(simplifiedReports))
is called to fetch the avatar thumbnails asynchronously (usingAPI.PersonalDetails_GetForEmails
), which resolves after callingOnyx.mergeCollection(ONYXKEYS.COLLECTION.REPORT, simplifiedReports)
which triggers a re-render synchronously and calls the functioncreateOption
before fetching the avatars:My hypothesis is that the avatar won't appear if
API.PersonalDetails_GetForEmails
doesn't resolve because of a connection issue (i.e. internet goes offline exactly when the app is fetching the avatars). So I added more conditions to check not only if thereport
object exists but also theicons
andicons[0]
has a valid value; I found sometimesicons[0]
is an empty string too: https://github.com/Expensify/App/blob/main/src/libs/OptionsListUtils.js#L760 (which is called inPersonalDetails.getFromReportParticipants
).Seems the issue was only reproducible on Desktop and Web.
Fixed Issues
$ #5232
Tests
QA Steps
Tested On
Screenshots
Web
Mobile Web
Desktop
iOS
Android