fix: not switching to proper conversation when navigating from notification [WPB-4294] #2231
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.
Cherry pick from the original PR:
PR Submission Checklist for internal contributors
The PR Title
SQPIT-764
The PR Description
What's new in this PR?
Issues
Tapping on notification does not forward the user to the according conversation when another conversation is open.
Causes (Optional)
Compose destinations library has two interfaces containing
route
parameter that can't be used interchangeably.Route
is used to define destinations and its route is always a template with arguments placeholders, like the native compose navigation uses, for example:conversation_screen/{conversationId}
. As documentation states:Route
instances are not suited to navigate to unless they're alsoDirection
.Direction
also has aroute
parameter, but it's the specific route with filled proper arguments, likeconversation_screen/id123456
as it's used when navigating. So,route
parameters of both types shouldn't be compared.Because it couldn't compare it properly, it couldn't find the destination of the same type in the back stack. Together with
launchSingleTop
set to true, when we have already a destination of typeConverstationScreen
at the top of the back stack, it won't be replaced with a new one, thus when opening anotherConversationScreen
it still keeps the previous one on screen and ignores the new one.Solutions
Instead of comparing full routes, extract the base of each route, which is unique for each destination, and then compare only that part to find the specific destination type in the back stack.
Testing
How to Test
Open conversation A, receive notification for conversation B, click on that notification - the app should open the conversation B screen.
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
.