Repository navigation
[CP Staging] Fix crash when navigating to new public room - #41219
Conversation
|
Minor change, seeking internal review |
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / SafariScreen.Recording.2024-04-29.at.11.32.26.AM.movMacOS: Desktop |
| result.participantsList = participantPersonalDetailList; | ||
|
|
||
| result.icons = ReportUtils.getIcons(report, personalDetails, UserUtils.getAvatar(personalDetail?.avatar ?? {}, personalDetail?.accountID), '', -1, policy); | ||
| result.icons = ReportUtils.getIcons(report, personalDetails, UserUtils.getAvatar(personalDetail?.avatar ?? '', personalDetail?.accountID), '', -1, policy); |
There was a problem hiding this comment.
It's weird that the {} doesn't throw a type error. Do you think we should add avatarSource is string | undefined like we do here.
There was a problem hiding this comment.
I think it returns if avatar source is string or undefined and if we should use default avatar. It does not necessarily ensure type. we can have something like -
if (typeof(avatarSource) !== string or typeof(avatarSource) !== undefined) throw TypeCheckError;Let's discuss in slack and do as a follow up?
There was a problem hiding this comment.
I think we should just add a empty object check in ReportUtils.getIcons. When it's empty, we can just use the FallbackAvatar. Right now empty object is still a valid for the AvatarSource type so someone can still re-introduce this bug without noticing.
There was a problem hiding this comment.
I think we should just add a empty object check in ReportUtils.getIcons
It doesn't fully solve the concern of reintroducing this crash again, no? There are other places too where we call Avatar methods - getAvatar() and AvatarSource argument type is {} and it is returned as {} causing such crashes
Right now empty object is still a valid for the AvatarSource type so someone can still re-introduce this bug without noticing.
Right, how about throwing as mentioned above
There was a problem hiding this comment.
It doesn't fully solve the concern of reintroducing this crash again, no?
For this crash it would. The root problem was that ReportUtils.getIcons is returning an invalid source when given certain params. I think we should just fix that by validating the params and returning the fallback if validation fails. We can write a isValidAvatarSource function and use it where needed.
Right, how about throwing as mentioned above
I'm not sure how that helps honestly. Does that not also crash the app?
There was a problem hiding this comment.
For this crash it would. The root problem was that ReportUtils.getIcons is returning an invalid source when given certain params. I think we should just fix that by validating the params and returning the fallback if validation fails
Agree with this. I meant if we have this logic at lower level function like getAvatar(), it would help us to catch all errors as ReportUtils.getIcons was getting defaultIcon argument that resulted from getAvatar()
We can write a isValidAvatarSource function and use it where needed
Sounds good 👍
and if the check fails, we return avatarSource as empty string, correct?
I'm not sure how that helps honestly. Does that not also crash the app?
Yes, if someone added such param then it would throw the error so we can catch it during testing
There was a problem hiding this comment.
Oh okay I see. I think we should probably validate in both places just to be safe. For ReportUtils.getIcons I think we should just return the FallbackAvatar when the given AvatarSource is invalid. I'm not sure about other places though.
Yes, if someone added such param then it would throw the error so we can catch it during testing
We're already throwing an error and crashing the app as it is. So I don't think throwing a different error will make the bug more noticeable in testing. I think we should always avoid crashing the app and just log the error instead. That way we can still catch it in testing and if we don't, the app isn't crashing for users.
[CP Staging] Fix crash when navigating to new public room (cherry picked from commit 4db1763)
|
🚀 Cherry-picked to staging by https://github.com/francoisl in version: 1.4.67-2 🚀
@Expensify/applauseleads please QA this PR and check it off on the deploy checklist if it passes. |
|
@MonilBhavsar Can you please link the second blocker and add the QA steps so it also tests the second blocker (once applause retests)? Thanks! |
|
🚀 Deployed to production by https://github.com/francoisl in version: 1.4.67-7 🚀
|
1 similar comment
|
🚀 Deployed to production by https://github.com/francoisl in version: 1.4.67-7 🚀
|
Details
Fixes a crash in
ImageSVGcomponent when we're trying to render an empty objectFixed Issues
$ #41170
$ #41130
PROPOSAL:
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
See MacOS: Chrome / SafariAndroid: mWeb Chrome
See MacOS: Chrome / SafariiOS: Native
See MacOS: Chrome / SafariiOS: mWeb Safari
See MacOS: Chrome / SafariMacOS: Chrome / Safari
Screen.Recording.2024-04-29.at.8.41.51.PM.mov
MacOS: Desktop
See MacOS: Chrome / Safari