Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
51 changes: 51 additions & 0 deletions app/src/test/java/com/anindra/messages/ui/InboxSkeletonTest.kt
Original file line number Diff line number Diff line change
@@ -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)
)
}
}