The player gains a queue sheet showing the current track and every upcoming track, with move up/down and remove; changes are persisted in the playback snapshot. Music and longform are now separate: library sync splits songs by the user's folder assignments, so longform no longer leaks into search, Shuffle all or moods. The new Longform tab groups audiobooks and podcasts by artist, offers a generated read-only playlist per artist, "Shuffle artist" for random tracks, separate longform search, and a Continue listening list with progress bars and resume. Positions are saved locally and to the server while playing, on pause and on track changes. Recommendation cards now show download progress (queued, downloading, failed with error and retry) and the mood refreshes while downloads are running.
This commit is contained in:
1 parent
dc719f3e1a
commit
c0ff586686
10 files changed
+796
-31
No files matched your search
@@ -220,6 +220,91 @@ class AppStoreTest {
|
||||
* Ktor's mock engine responds on a real dispatcher, so queued test work has
|
||||
* to be run between short real waits.
|
||||
*/
|
||||
|
||||
@Test
|
||||
fun `queue reordering and removal persist`() = runTest {
|
||||
val storage = MemoryStorage()
|
||||
val cache = LibraryCache(storage)
|
||||
cache.save(CachedState(serverUrl = "http://music", songs = listOf(song("a"), song("b"), song("c"))))
|
||||
val player = FakePlayer()
|
||||
val store = store(storage, cache, player)
|
||||
runCurrent()
|
||||
|
||||
store.playAll(shuffled = false)
|
||||
runCurrent()
|
||||
assertEquals("a", store.state.value.current?.id)
|
||||
assertEquals(listOf("b", "c"), store.state.value.queue.map { it.id })
|
||||
|
||||
store.moveInQueue(1, 0)
|
||||
assertEquals(listOf("c", "b"), store.state.value.queue.map { it.id })
|
||||
|
||||
store.removeFromQueue(0)
|
||||
assertEquals(listOf("b"), store.state.value.queue.map { it.id })
|
||||
assertEquals(listOf("b"), cache.loadPlayback()?.queue?.map { it.id })
|
||||
store.release()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `playing an artist queues only that longform artist`() = runTest {
|
||||
val storage = MemoryStorage()
|
||||
val cache = LibraryCache(storage)
|
||||
cache.save(
|
||||
CachedState(
|
||||
serverUrl = "http://music",
|
||||
longform = listOf(
|
||||
song("l1", artist = "Die drei ???", folderId = 10),
|
||||
song("l2", artist = "Die drei ???", folderId = 10),
|
||||
song("l3", artist = "Other", folderId = 10),
|
||||
),
|
||||
),
|
||||
)
|
||||
val player = FakePlayer()
|
||||
val store = store(storage, cache, player)
|
||||
runCurrent()
|
||||
|
||||
store.playLongformArtist("Die drei ???", shuffled = false)
|
||||
runCurrent()
|
||||
|
||||
val state = store.state.value
|
||||
assertEquals(setOf("l1", "l2"), (state.queue + listOfNotNull(state.current)).map { it.id }.toSet())
|
||||
assertTrue(player.played.single() in setOf("l1", "l2"))
|
||||
store.release()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `resuming a longform track starts it`() = runTest {
|
||||
val storage = MemoryStorage()
|
||||
val cache = LibraryCache(storage)
|
||||
cache.save(
|
||||
CachedState(
|
||||
serverUrl = "http://music",
|
||||
longform = listOf(song("l1", artist = "Die drei ???", folderId = 10)),
|
||||
),
|
||||
)
|
||||
cache.saveProgress(
|
||||
listOf(
|
||||
win.taptap.musicmanager.client.api.LongformProgress(
|
||||
songId = "l1",
|
||||
positionSeconds = 30,
|
||||
durationSeconds = 180,
|
||||
completed = false,
|
||||
updatedAt = "2026-01-01T00:00:00Z",
|
||||
),
|
||||
),
|
||||
)
|
||||
val player = FakePlayer()
|
||||
val store = store(storage, cache, player)
|
||||
runCurrent()
|
||||
|
||||
store.resumeLongform("l1")
|
||||
runCurrent()
|
||||
|
||||
assertEquals("l1", store.state.value.current?.id)
|
||||
assertEquals(listOf("l1"), player.played)
|
||||
assertEquals(30, store.state.value.longformProgress["l1"]?.positionSeconds)
|
||||
store.release()
|
||||
}
|
||||
|
||||
private suspend fun TestScope.awaitState(predicate: () -> Boolean) {
|
||||
repeat(500) {
|
||||
runCurrent()
|
||||
@@ -260,17 +345,17 @@ class AppStoreTest {
|
||||
cache = cache,
|
||||
)
|
||||
|
||||
private fun song(id: String) = Song(
|
||||
private fun song(id: String, artist: String = "Artist", folderId: Int = 1) = Song(
|
||||
id = id,
|
||||
title = "Song $id",
|
||||
artist = "Artist",
|
||||
artist = artist,
|
||||
album = "Album",
|
||||
albumId = "al-1",
|
||||
duration = 180,
|
||||
bitRate = 320,
|
||||
size = 1_000,
|
||||
suffix = "mp3",
|
||||
folderId = 1,
|
||||
folderId = folderId,
|
||||
relativePath = "$id.mp3",
|
||||
updatedAt = "2026-01-01T00:00:00Z",
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user