allow queue loading during drag; keep the album title after a reorder

- the mid-drag load guard also stopped the window extending while
  auto-scrolling, so dragging a context row over a long up-next block hit
  the loaded edge and dropped. Removed it: loadOlder/loadNewer now extend
  from the min/max loaded position, which is what prevents the duplicates.
- a reordered track becomes an explicit song entry, so the context kind
  switches to Song and the queue title fell back to "Next from here".
  sourceName now resolves a song entry to its album so the title keeps
  the album name.
This commit is contained in:
austinried
2026-10-04 00:30:00 +00:00
parent b189ae0cc5
commit 718dcf31bd
3 changed files with 26 additions and 4 deletions
@@ -190,8 +190,14 @@ class QueueRepository(
?.takeIf { it.isNotBlank() }
}
// An explicit song entry in the middle of a queue is a reordered context track, so
// label it by its album rather than losing the context name.
QueueKind.Song -> {
null
library
.song(sourceId, refId)
.first()
?.album
?.takeIf { it.isNotBlank() }
}
}
}
@@ -349,9 +349,6 @@ fun QueueScreen(
val last = info.visibleItemsInfo.lastOrNull { it.key is Long }?.let { rows.rowIndexOf(it.key) } ?: -1
first to last
}.collect { (first, last) ->
// Mid-drag the live reorder leaves row positions inconsistent, so extending here would
// re-add rows that are already loaded.
if (dragId != null) return@collect
if (first in 0..LOAD_THRESHOLD) onLoadOlder()
if (last >= 0 && last >= rows.size - 1 - LOAD_THRESHOLD) onLoadNewer()
}
@@ -1001,6 +1001,25 @@ class PlaybackControllerTest {
assertEquals(runBlocking { queues.combinedIndexOf(snapshot, "s3") }, controller.state.value.position)
}
@Test
fun movingThePlayingContextTrackStillResolvesAnAlbumTitle() {
seedAlbum(3, sourceId = 1)
controller.playAlbum(1, "al1", 1)
await {
controller.state.value.item
?.id == "s2"
}
runBlocking { controller.move(1, 0) }
await {
controller.state.value.item
?.id == "s2"
}
assertEquals("Album", runBlocking { controller.sourceTitle(controller.state.value.context) })
}
@Test
fun nextFollowsTheReorderedQueue() {
seedAlbum(3, sourceId = 1)