Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

notif: Preserve target account context on back navigation after opening a notification #1373

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lakshya1goel
Copy link
Contributor

Fixes: #1210

Description

When opening a notification from a different account B while in account A and pressing back, the app should stay in account B's context rather than returning to account A. This PR implements this behavior by:

  1. Checking if the current route belongs to a different account than the notification's target account
  2. If so, navigating to the target account's homepage before pushing the message list
  3. This ensures the navigation stack has the proper account context, making back navigation intuitive

Video Demonstration

WhatsApp.Video.2025-02-22.at.10.34.48.PM.mp4

@lakshya1goel lakshya1goel changed the title notif: Ensure back navigation preserves target account context after … notif: Ensure back navigation preserves target account context after opening notification Feb 22, 2025
@lakshya1goel lakshya1goel changed the title notif: Ensure back navigation preserves target account context after opening notification notif: Preserve target account context on back navigation after opening a notification Feb 22, 2025
|| (topRoute as AccountRoute).accountId != route.accountId) {
HomePage.navigate(context, accountId: route.accountId);
navigator = await ZulipApp.navigator;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The popUntil above unconditionally clears the navigator stack until there is only one route left. I believe that this is equivalent to HomePage.navigate, which also pops all routes beforehand.

Either way, we should not pop all routes unconditionally, because it doesn't feel like great user experience when the existing routes already belong to the same account.

#F1210 suggests that we

switch to a new nav stack for the notification's account (if different) before pushing the message-list route.

I think what we need here is just a way to keep track of the currently active account, or a way to inspect the navigator stack without actually popping the routes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See discussion here: #mobile > Beta: after open via notification, back opens old server @ 💬. Feel free to ask questions if you have any!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

android: When opening a notification, "back" should not leave the account's context
2 participants