mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-10 06:17:25 +00:00
feat(satellites): 勾选置顶显示——已选/可用分组+顶部计数条(对齐上游)
This commit is contained in:
10 files changed
+101
-3
No files matched your search
+10
-1
@@ -66,8 +66,17 @@ class SelectionRepo(
|
||||
}
|
||||
}
|
||||
|
||||
// Selected satellites are pinned to the top (matches upstream); ordering
|
||||
// within each group stays name/catnum. Sits on the reactive chain, so
|
||||
// ticking an entry re-sorts the visible list immediately.
|
||||
private val itemsWithQuery = currentQuery.flatMapLatest { query ->
|
||||
itemsWithTypes.map { items -> filterByQuery(items, query) }
|
||||
itemsWithTypes.map { items ->
|
||||
filterByQuery(items, query).sortedWith(
|
||||
compareByDescending<SatItem> { it.isSelected }
|
||||
.thenBy { it.name }
|
||||
.thenBy { it.catnum }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getCurrentTypes() = currentTypes.value
|
||||
|
||||
+18
@@ -284,6 +284,24 @@ class SelectionRepoSearchTest {
|
||||
assertEquals(sampleItems.map { it.catnum }.toSet(), results.map { it.catnum }.toSet())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `selected satellites are shown first`() = runTest {
|
||||
// Pinning ported from upstream: ticked satellites sort above the rest,
|
||||
// each group keeping the name order.
|
||||
val repo = createRepo(
|
||||
items = listOf(
|
||||
SatItem(catnum = 44444, name = "Zeta"),
|
||||
SatItem(catnum = 25544, name = "Alpha"),
|
||||
SatItem(catnum = 40967, name = "Beta")
|
||||
)
|
||||
)
|
||||
val flow = repo.getEntriesFlow()
|
||||
repo.setSelection(listOf(40967), true)
|
||||
val results = flow.first()
|
||||
assertEquals(listOf(40967, 25544, 44444), results.map { it.catnum })
|
||||
assertEquals(listOf(true, false, false), results.map { it.isSelected })
|
||||
}
|
||||
|
||||
private fun createRepo(
|
||||
items: List<SatItem>,
|
||||
sstvIds: List<Int> = emptyList()
|
||||
|
||||
Reference in new issue
Block a user