Repository navigation
fix(notifications): ensure notification tap always opens target email - #67
Open
arnauda-gh wants to merge 2 commits into
Open
arnauda-gh wants to merge 2 commits into
arnauda-gh wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes an issue where tapping a notification sometimes opened the wrong email (specifically the newest email received in the inbox rather than the email from the notification).
Root Causes
navigateToNotificationTapnavigated toEmailThread, it did not passemailIds: [payload.emailId]. If the target email was present in the cached folder list (e.g. Inbox) and a newer email had arrived in the meantime,viewerPagesreturned the entire folder list with the newly arrived email at index 0 and the target email at index > 0.initialNumToRenderwas set to 1 and noonScrollToIndexFailedhandler was configured,FlatListon Android failed to scroll toinitialScrollIndexbefore the initial layout pass completed, getting stuck at scroll offset 0 (which rendered the newly arrived email at index 0). Touching or scrolling then causedonMomentumScrollEndto reassignactiveEmailIdto the newly arrived email.BulwarkFcmModule.ktcreated notification intents without a uniquedataURI, which underFLAG_ACTIVITY_SINGLE_TOPcould cause Android to deliver stale/reused intent extras whenMainActivitywas already alive.BulwarkFcmModule.ktposted a group summary even when there was only 1 notification active. Tapping a collapsed notification group triggered the summary'sPendingIntent(which had noemailId), taking the user to the inbox instead of the tapped email.Solution
App.tsx: PassemailIds: [payload.emailId]innavigateToNotificationTapso the viewer mounts as a dedicated single-page view for the tapped email, as intended byviewerPages.src/screens/EmailThreadScreen.tsx: SetinitialNumToRender={Math.max(initialIndexRef.current + 1, 1)}and implementonScrollToIndexFailedon the pagerFlatListto prevent the pager from ever getting stuck at index 0 when navigating to an index > 0.android/app/src/main/java/com/anonymous/bulwarkmobile/BulwarkFcmModule.kt:data = Uri.parse("bulwark-notification://$notificationId")(and for group summaries) so Android's intent filter matcher treats each notification intent as unique.children.size >= 2, and cancel any existing summary when fewer than 2 child notifications remain.src/lib/__tests__/viewer-pages.test.ts.!! AI WARNING !! : This PR was generated and created by AI. It has been tested on my own use case and seems to work. However have a deep look about the generated code.