Modern Apps git

← Modern-Apps.git

securemail: fix taps on a message doing nothing

Commit
e4aa0a84912ccfb786145052597af6cc8164b86b
Author
Vayun Mathur <[email protected]>
When
2026-11-02 06:27 UTC (1 month ago)
Parents
426f216
Tapping a message in any folder no longer opened the reader (no crash,
no log line); long-press selection still worked. Reproduced over adb on
a Pixel 9 Pro XL.

rememberNavBackStack keys the retained stack on the start route, and
Navigation's start route moves Onboarding -> Lock -> Inbox while the
settings flow loads, so the back stack instance is replaced during
startup. folderActions (and the Out page's OutActions) were built with
remember(viewModel) and so kept the first stack: onOpen pushed
Route.Reader onto a stack nothing displays. Bottom-bar navigation and
long-press were unaffected because they read the current stack /
local state directly.

Both remembers are now keyed on backStack as well, so the callbacks
are rebuilt when the stack is replaced.

Verified: :securemail:compileDevKotlin, unit tests, lint clean, detekt
unchanged at 40. Not yet confirmed on device: ./install refused to
replace the phone's build (INSTALL_FAILED_UPDATE_INCOMPATIBLE,
different signing key).

Diff

securemail/src/main/java/com/vayunmathur/securemail/Navigation.kt
diff --git a/securemail/src/main/java/com/vayunmathur/securemail/Navigation.kt b/securemail/src/main/java/com/vayunmathur/securemail/Navigation.ktindex 6393bb0094..256c3933e1 100644--- a/securemail/src/main/java/com/vayunmathur/securemail/Navigation.kt+++ b/securemail/src/main/java/com/vayunmathur/securemail/Navigation.kt@@ -61,7 +61,11 @@ fun Navigation(viewModel: MailViewModel, initialRoute: Route? = null) {         if (initialRoute != null) backStack.add(initialRoute)     } -    val folderActions = remember(viewModel) {+    // Keyed on backStack too: the stack is keyed on the start route, which moves+    // Onboarding -> Lock -> Inbox while settings load, so it is replaced during+    // startup. Callbacks holding the first stack would push onto a stack that+    // is no longer displayed (taps on a message silently did nothing).+    val folderActions = remember(viewModel, backStack) {         FolderActions(             onOpen = { backStack.add(Route.Reader(it)) },             onCompose = { backStack.add(Route.Composer()) },@@ -238,7 +242,7 @@ private fun EntryProviderScope<Route>.outEntry(viewModel: MailViewModel, backSta         val drafts by viewModel.drafts.drafts.collectAsState(emptyList())         val sent by viewModel.drafts.sent.collectAsState(emptyList())         val outbox by viewModel.outboxMessages.collectAsState(emptyList())-        val actions = remember(viewModel) {+        val actions = remember(viewModel, backStack) {             OutActions(                 onCompose = { backStack.add(Route.Composer()) },                 onOpenDraft = { d ->