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

Fix notification navigation #2780

Merged
merged 5 commits into from
May 2, 2024
Merged

Conversation

bmarty
Copy link
Member

@bmarty bmarty commented May 1, 2024

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Rework how the navigation is handled regarding FtueState, and permalink.

Motivation and context

Closes #2778

Screenshots / GIFs

Tests

  • Receive a notification
  • Kill the app
  • Click on the notification
  • If the room is displayed, the issue is fixed.

As a bonus, permalink will work (until a room or a user is displayed), even if there are Ftue step to perform and even an account to log in.

This can be tested using deeplink.sh combine with the internal clear cache option, which reset some Ftue steps.

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

@bmarty bmarty requested a review from a team as a code owner May 1, 2024 12:06
@bmarty bmarty requested review from jmartinesp and removed request for a team May 1, 2024 12:06
.lastOrNull(predicate)
if (node != null && !continuation.isCompleted) {
continuation.resume(Unit)
cancel()
Copy link
Member Author

Choose a reason for hiding this comment

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

I think cancel() should also be invoked after line 45, since once the continuation is resumed, there is no need to invoke the predicated until the Node is destroyed.

But I do not want to do it in that PR.

Copy link
Contributor

@jmartinesp jmartinesp May 2, 2024

Choose a reason for hiding this comment

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

It seems like this also happens in the original ParentNode.waitForChildAttached(). That's kind of weird. It could be solved if they didn't use collect, but mapNotNull and then a suspending firstOrNull() or something like that, but keeping the cancel here is fine too.

@bmarty bmarty added the Run-Maestro Starts a Maestro Cloud session to run integration tests label May 1, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label May 1, 2024
Copy link
Contributor

github-actions bot commented May 1, 2024

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/xoFZsF

Copy link

codecov bot commented May 1, 2024

Codecov Report

Attention: Patch coverage is 0% with 11 lines in your changes are missing coverage. Please review.

Project coverage is 73.45%. Comparing base (9880579) to head (f807d57).

Files Patch % Lines
...nt/android/libraries/architecture/ParentNodeExt.kt 0.00% 11 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #2780      +/-   ##
===========================================
- Coverage    73.47%   73.45%   -0.02%     
===========================================
  Files         1517     1517              
  Lines        36422    36431       +9     
  Branches      7012     7013       +1     
===========================================
  Hits         26760    26760              
- Misses        5997     6006       +9     
  Partials      3665     3665              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

sonarcloud bot commented May 1, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

Copy link
Contributor

@jmartinesp jmartinesp left a comment

Choose a reason for hiding this comment

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

Depending on whether we want to re-use the verification flow in the future we might want to keep the Callback even if we don't use it on LoggedInFlowNode, but we could always just restore it in that case.

I also have a question about waitForNavTargetAttached when the room list can't be displayed for some reason.

.lastOrNull(predicate)
if (node != null && !continuation.isCompleted) {
continuation.resume(Unit)
cancel()
Copy link
Contributor

@jmartinesp jmartinesp May 2, 2024

Choose a reason for hiding this comment

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

It seems like this also happens in the original ParentNode.waitForChildAttached(). That's kind of weird. It could be solved if they didn't use collect, but mapNotNull and then a suspending firstOrNull() or something like that, but keeping the cancel here is fine too.

suspend fun attachRoom(roomId: RoomId) {
if (!canShowRoomList()) return
waitForNavTargetAttached { navTarget ->
Copy link
Contributor

Choose a reason for hiding this comment

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

What if the user is in the middle of FTUE when they tap on the notification? Shouldn't we add some kind of timeout or additional check? Otherwise I think this function will be suspended until then and suddenly resumed and the user presented with the room, and if they tap on several notifications I think they all will be suspended and suddenly resumed at the same time.

Copy link
Member Author

Choose a reason for hiding this comment

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

mmh, I did not test the use case of tapping a notification (neither tapping on multiple ones) when a ftue screen is displayed, I will test it.

But if at the end the room is displayed, I think this is the expected behavior.

As I said in the description, if the user clicks on a room permalink from outside the app, the user may have to log in first and at the end will se the room, because this method is suspending.

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO that behaviour is bit weird, what if:

  1. The user taps on a notification for a room, it opens the app with FTUE displayed.
  2. Then they tap on a notification for another room.
  3. They finish the FTUE flow.

What will happen then? Will the 1st room be opened, the 2nd one, or both one after the other?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I just checked and all the rooms will be added to the backstack, and several back press will be necessary to go back to the room list. I think this is OK since:

  • it will not happen a lot (FTUE screen are only for the first time, by definition)
  • the user has performed action (click) so is expecting to see the room at some point.

We could ensure that the same room is not added twice on the backstack (i.e. click on a first notification, then get another one for the same room and click on this new one), but really this is edge cases, and this can be handled later if this is a reported issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should handle it here since we have the chance now, but if it's blocking some other PR I can approve it as is and we can handle it later.

Copy link
Contributor

@jmartinesp jmartinesp 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 fixing the issue!

@bmarty
Copy link
Member Author

bmarty commented May 2, 2024

Depending on whether we want to re-use the verification flow in the future we might want to keep the Callback even if we don't use it on LoggedInFlowNode, but we could always just restore it in that case.

Yeah, I hesitated before removing this code, but I preferred to remove it so that it's clear that it's not used at the moment.

The navigation part is a bit tricky, and so less code, less headache :)

backstack.push(NavTarget.Room(roomId.toRoomIdOrAlias()))
}
}

private fun canShowRoomList(): Boolean {
return ftueService.state.value is FtueState.Complete
Copy link
Member Author

Choose a reason for hiding this comment

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

By the way, after a cold boot, ftueService.state.value was equal to Unknown which was the root cause of the issue this PR is fixing.

@bmarty bmarty merged commit 682fd45 into develop May 2, 2024
14 of 16 checks passed
@bmarty bmarty deleted the feature/bma/fixNotificationNavigation branch May 2, 2024 10:11
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.

Clicking on a notification does not open the target room anymore, if the app is not yet started
2 participants