Skip to content

Conversation

@rajveermalviya
Copy link
Member

Previously, opening a notification from a different account would leave the home page on a different account than the newly opened message list.

Now, if the notification's account is different from currently viewing account, we change the whole navigation stack: pop all routes, push HomePage, push MessageList

Fixes: #1210

Previously, opening a notification from a different account would
leave the home page on a different account than the newly opened
message list.

Now, if the notification's account is different from currently
viewing account, we change the whole navigation stack:
pop all routes, push HomePage, push MessageList

Fixes: zulip#1210
@rajveermalviya rajveermalviya added the maintainer review PR ready for review by Zulip maintainers label Nov 19, 2025
Copy link
Collaborator

@chrisbobbe chrisbobbe left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM, marking for Greg's review.

@chrisbobbe chrisbobbe requested a review from gnprice November 21, 2025 01:22
@chrisbobbe chrisbobbe assigned gnprice and unassigned chrisbobbe Nov 21, 2025
@chrisbobbe chrisbobbe added integration review Added by maintainers when PR may be ready for integration and removed maintainer review PR ready for review by Zulip maintainers labels Nov 21, 2025
Copy link
Member

@gnprice gnprice left a comment

Choose a reason for hiding this comment

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

Thanks for taking care of this! Comments below.

Let's also add a short test case that's specifically about this behavior. The existing test cases that exercise it do so kind of by accident.

int? prevAccountId,
}) async {
await openNotification(tester, account, message);
if (expectHomePageReplaced) takeHomePageReplacement(account.id, prevAccountId!);
Copy link
Member

Choose a reason for hiding this comment

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

Should also check that we don't pop any routes when that's not expected (when the account didn't change).

Comment on lines +192 to +198
void takeHomePageReplacement(int accountId, int prevAccountId) {
check(poppedRoutes).last.which(
(it) => it.isA<MaterialAccountWidgetRoute>()
..accountId.equals(prevAccountId)
..page.isA<HomePage>());
// We only care about HomePage being the last popped route.
poppedRoutes.clear();
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't match the meaning of our other "takeFoo" helpers, in this or other tests: generally those all consume exactly the items that they check the details of, and consume them in the order they happened.

In this version, it not only ignores any non-HomePage routes before the last, but also any extra HomePage routes before the last one popped. So e.g. if a test popped two different HomePage routes and only then called this function, this would look only at the last one (but then in the next line it would look at the first route pushed, a potentially-confusing mismatch).

If you only ever want to look at the last route popped, probably clearest to only maintain that data: like Route<void>? lastPoppedRoute, instead of a list.

Comment on lines +199 to +203
check(pushedRoutes).first.which(
(it) => it.isA<MaterialAccountWidgetRoute>()
..accountId.equals(accountId)
..page.isA<HomePage>());
pushedRoutes.removeAt(0);
Copy link
Member

Choose a reason for hiding this comment

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

This is the same as a call to takeHomePageRouteForAccount, right?

Comment on lines +308 to +310
await checkOpenNotification(tester,
accounts[1], eg.streamMessage(),
expectHomePageReplaced: true, prevAccountId: accounts[0].id);
Copy link
Member

Choose a reason for hiding this comment

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

Specifying the previous account ID seems redundant here: the HomePage that gets popped is necessarily going to be the one that had been on the stack in the first place. The key question is whether it gets popped or not.

Comment on lines 293 to +295
await testBinding.globalStore.add(
accounts[0], eg.initialSnapshot(realmUsers: [user1]));
accounts[0], eg.initialSnapshot(realmUsers: [user1]),
markLastVisited: true);
Copy link
Member

Choose a reason for hiding this comment

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

I think markLastVisited is best avoided in general. It makes the test more complicated, and it does so by making it behave differently from how the real app behaves: in the real app, when an account gets added to the global store, that's always accompanied by visiting that account.

Here, if you want accounts[0] to be the one last visited, that can be done by reversing the order of the globalStore.add calls. Alternatively (and probably clearer), can let accounts[3] be the last visited, and reverse the order of the checkOpenNotification calls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration review Added by maintainers when PR may be ready for integration

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

3 participants