check if report.icons and report.icons[0] exists#5381
Merged
Conversation
tgolen
requested changes
Sep 22, 2021
| ? lastMessageText | ||
| : Str.removeSMSDomain(personalDetail.login); | ||
| } | ||
| const icons = (report && report.icons && report.icons[0]) ? report.icons : [personalDetail.avatar]; |
Contributor
There was a problem hiding this comment.
Can you please use Lodash.get instead for this? I think it would make this more simple.
Contributor
Author
|
Update: use |
tgolen
approved these changes
Sep 23, 2021
tgolen
left a comment
Contributor
There was a problem hiding this comment.
Ah, that looks great. Thanks!
Contributor
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
27 tasks
Contributor
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.actionssometimes isundefinedor has an array with an empty string (['']). This is because the links of the avatar thumbnails are fetched after inserting thesimplifiedReportsinto 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 functioncreateOptionbefore fetching the avatars:My hypothesis is that the avatar won't appear if
API.PersonalDetails_GetForEmailsdoesn'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 thereportobject exists but also theiconsandicons[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