fix: crash when uploading avatar [WPB-5965] #2673
Merged
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.
PR Submission Checklist for internal contributors
The PR Title
SQPIT-764
The PR Description
What's new in this PR?
Issues
It's one of the most frequently occurring crashes right now which happens during uploading new avatar.
Causes (Optional)
Sometimes, before the "current avatar" is downloaded, the
lateinit var currentAvatarUri
is not yet initialized, so when there's an error when uploading a new one, it crashes because it cannot set the "current" one back on the UI.Also happened when someone closed the screen while the avatar was still being uploaded - a "nice to have" would be an option to upload the avatar in the background.
Solutions
Provide a state of loading the current avatar and use its url when it's already downloaded, otherwise set it as
Empty
.The same can happen the other way around - when "current" avatar is downloaded later than the new one is uploaded, then it will not be wrongly overwritten.
Testing
Test Coverage (Optional)
How to Test
Have an account that doesn't have any avatar set, open the screen to update the avatar, turn off the network, choose an image and click "confirm" to try to upload a new avatar. Uploading will fail so the snackbar message should appear but the app shouldn't crash.
PR Post Submission Checklist for internal contributors (Optional)
PR Post Merge Checklist for internal contributors
References
feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764
.