diff --git a/app/src/main/java/com/anindra/messages/ui/ConversationsScreen.kt b/app/src/main/java/com/anindra/messages/ui/ConversationsScreen.kt index 551fafc9..c9ea9e2e 100644 --- a/app/src/main/java/com/anindra/messages/ui/ConversationsScreen.kt +++ b/app/src/main/java/com/anindra/messages/ui/ConversationsScreen.kt @@ -235,7 +235,11 @@ fun ConversationsScreen( mutableStateOf(vm.hasLoadedOnce || vm.settings.firstImportDone) } // skeleton stays while importing; denied SMS access ends it (panel takes over) - val loaded = minSkeletonShown && (syncDone || !readSmsAllowed) + // "First import done" is persisted, so an update that re-imports (or a + // migration that rewrites threads) still starts with it true: trusting the + // flag alone skipped the skeleton and left a blank list on screen while the + // work ran. A sync in flight keeps the skeleton and its progress bar. + val loaded = minSkeletonShown && syncProgress == null && (syncDone || !readSmsAllowed) var sheetConvoId by remember { mutableLongStateOf(-1L) } val sheetConvo = conversations.find { it.id == sheetConvoId } // #340: long-press starts a multi-conversation selection so several threads diff --git a/app/src/main/java/com/anindra/messages/ui/legacy/LegacyConversationsScreen.kt b/app/src/main/java/com/anindra/messages/ui/legacy/LegacyConversationsScreen.kt index 5757fba2..7401d40e 100644 --- a/app/src/main/java/com/anindra/messages/ui/legacy/LegacyConversationsScreen.kt +++ b/app/src/main/java/com/anindra/messages/ui/legacy/LegacyConversationsScreen.kt @@ -221,7 +221,11 @@ fun ConversationsScreen( mutableStateOf(vm.hasLoadedOnce || vm.settings.firstImportDone) } // skeleton stays while importing; denied SMS access ends it (panel takes over) - val loaded = minSkeletonShown && (syncDone || !readSmsAllowed) + // "First import done" is persisted, so an update that re-imports (or a + // migration that rewrites threads) still starts with it true: trusting the + // flag alone skipped the skeleton and left a blank list on screen while the + // work ran. A sync in flight keeps the skeleton and its progress bar. + val loaded = minSkeletonShown && syncProgress == null && (syncDone || !readSmsAllowed) var sheetConvoId by remember { mutableLongStateOf(-1L) } // #340: long-press starts a multi-conversation selection so several threads // can be deleted in one go. The redesigned list carries the same bar. diff --git a/app/src/test/java/com/anindra/messages/ui/InboxSkeletonTest.kt b/app/src/test/java/com/anindra/messages/ui/InboxSkeletonTest.kt new file mode 100644 index 00000000..2dabbcff --- /dev/null +++ b/app/src/test/java/com/anindra/messages/ui/InboxSkeletonTest.kt @@ -0,0 +1,51 @@ +package com.anindra.messages.ui + +import org.junit.Assert.assertTrue +import org.junit.Test +import java.io.File + +/** + * The inbox used to keep its skeleton (and the progress bar above it) while an + * import ran. After an update the persisted "first import done" flag is already + * true, so gating the skeleton on that flag alone skipped it and left an empty, + * black screen while the re-import worked through thousands of threads. + */ +class InboxSkeletonTest { + + private val main: File by lazy { + generateSequence(File("").absoluteFile) { it.parentFile } + .map { File(it, "app/src/main") } + .firstOrNull { File(it, "java").isDirectory } + ?: error("app/src/main not found") + } + + private fun src(path: String) = File(main, path).readText() + + @Test + fun aSyncInFlightKeepsTheSkeletonOnBothScreens() { + listOf( + "java/com/anindra/messages/ui/ConversationsScreen.kt", + "java/com/anindra/messages/ui/legacy/LegacyConversationsScreen.kt" + ).forEach { path -> + val screen = src(path) + assertTrue( + "$path: the skeleton must survive a running import", + Regex("""val loaded = minSkeletonShown && syncProgress == null""").containsMatchIn(screen) + ) + assertTrue( + "$path: and the progress bar is still wired to the same state", + screen.contains("syncProgress?.let") + ) + } + } + + @Test + fun theFlagAloneIsNoLongerTreatedAsLoaded() { + val screen = src("java/com/anindra/messages/ui/ConversationsScreen.kt") + assertTrue( + "the persisted flag alone must not hide the loading state", + !Regex("""val loaded = minSkeletonShown && \(syncDone \|\| !readSmsAllowed\)""") + .containsMatchIn(screen) + ) + } +}