From 718dcf31bd158553a6a3ee9aefd8e31a7c91680e Mon Sep 17 00:00:00 2001 From: austinried <4966622+austinried@users.noreply.github.com> Date: Sun, 27 Sep 2026 01:59:39 +0000 Subject: [PATCH] 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. --- .../subtracks/data/repo/QueueRepository.kt | 8 +++++++- .../com/subtracks/ui/playback/QueueScreen.kt | 3 --- .../playback/PlaybackControllerTest.kt | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/com/subtracks/data/repo/QueueRepository.kt b/app/src/main/kotlin/com/subtracks/data/repo/QueueRepository.kt index 75668c2c..73f66649 100644 --- a/app/src/main/kotlin/com/subtracks/data/repo/QueueRepository.kt +++ b/app/src/main/kotlin/com/subtracks/data/repo/QueueRepository.kt @@ -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() } } } } diff --git a/app/src/main/kotlin/com/subtracks/ui/playback/QueueScreen.kt b/app/src/main/kotlin/com/subtracks/ui/playback/QueueScreen.kt index a2fb18fb..21ecd826 100644 --- a/app/src/main/kotlin/com/subtracks/ui/playback/QueueScreen.kt +++ b/app/src/main/kotlin/com/subtracks/ui/playback/QueueScreen.kt @@ -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() } diff --git a/app/src/test/kotlin/com/subtracks/playback/PlaybackControllerTest.kt b/app/src/test/kotlin/com/subtracks/playback/PlaybackControllerTest.kt index 3f76a33a..538148f6 100644 --- a/app/src/test/kotlin/com/subtracks/playback/PlaybackControllerTest.kt +++ b/app/src/test/kotlin/com/subtracks/playback/PlaybackControllerTest.kt @@ -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)