fix: crash when saving bottom sheet state for message with reply [WPB-14433] 🍒 #3695
+206
−22
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.
This PR was automatically cherry-picked based on the following PR:
Original PR description:
PR Submission Checklist for internal contributors
The PR Title
SQPIT-764
The PR Description
What's new in this PR?
Issues
After fixing bottom sheet crashes with this PR: #3670, still bottom sheet for message with a reply crashes.
Causes (Optional)
Android Studio had some problems highlighting all models that need to be serialized so previous PR missed out some of them. Also, turns out that using multiple serializer types can lead to some problems (in this case it was Json and Bundlizer).
Solutions
Make all classes used by
UIMessage
serializable, to be 100% sure.Replace Any primitive type serializer that uses Json with a more custom one that does it via surrogate.
Wrap serialization in try-catch so that if it fails, the app doesn't crash and only the bottom sheet is hidden as there's no saved state for it.
Update: after the discussion, it was decided to drop saving the state for now and come up with some solution to not store too much, especially for conversations and messages to not keep such data unencrypted anywhere, so in the future when there's time to do that we could slim down the models for the bottom sheets to save only required data and not any sensitive ones. For now
rememberSaveable
is replaced with regularremember
so the bottom sheet won't be rebuilt and the only drawback would be that the user would need to open it again.Testing
Test Coverage (Optional)
How to Test
Open conversation, long-click on a message with a reply to open the bottom sheet and put the app into background.
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
.