feat: choose Deezer or YouTube Music per mood
- models carry source and externalId instead of videoId - AppCache v3 discards the old shape - source selector in the create dialog, mood settings and search screen - switching source patches the mood and re-runs the search - client requests ten catalog results with a 60s timeout
This commit is contained in:
1 parent
96ab25a91d
commit
3b40726edb
14 files changed
+338
-76
No files matched your search
@@ -38,7 +38,7 @@ class ApiClientTest {
|
||||
)
|
||||
"/api/v1/moods" -> respond(
|
||||
"""
|
||||
{"moods":[{"id":"mo-1","name":"Focus","collectionPercent":60,
|
||||
{"moods":[{"id":"mo-1","name":"Focus","source":"deezer","collectionPercent":60,
|
||||
"recommendationPercent":40,"recommendationCount":10,"refreshHours":24,
|
||||
"createdAt":"now","changedAt":"now","songCount":2,"recommendationReady":3}]}
|
||||
""".trimIndent(),
|
||||
@@ -68,10 +68,10 @@ class ApiClientTest {
|
||||
"/api/v1/search" -> respond(
|
||||
"""
|
||||
{"results":[
|
||||
{"videoId":"v1","title":"Fresh","artist":"Artist","duration":180,
|
||||
"downloaded":false},
|
||||
{"videoId":"v2","title":"Old","artist":"Artist","duration":200,
|
||||
"songId":"sg-2","downloaded":true}
|
||||
{"source":"deezer","externalId":"v1","title":"Fresh","artist":"Artist",
|
||||
"duration":180,"downloaded":false},
|
||||
{"source":"deezer","externalId":"v2","title":"Old","artist":"Artist",
|
||||
"duration":200,"songId":"sg-2","downloaded":true}
|
||||
]}
|
||||
""".trimIndent(),
|
||||
HttpStatusCode.OK,
|
||||
@@ -98,8 +98,9 @@ class ApiClientTest {
|
||||
assertNull(results[0].songId)
|
||||
assertEquals("sg-2", results[1].songId)
|
||||
assertTrue(results[1].downloaded)
|
||||
assertEquals("v2", results[1].externalId)
|
||||
|
||||
val added = client.addSong("mo-1", videoId = "v1")
|
||||
val added = client.addSong("mo-1", source = "deezer", externalId = "v1")
|
||||
assertTrue(added.downloading)
|
||||
assertEquals(1, added.detail.mood.songCount)
|
||||
}
|
||||
@@ -112,8 +113,8 @@ class ApiClientTest {
|
||||
"""
|
||||
{"detail":{"mood":{"id":"mo-1","name":"Focus","createdAt":"now",
|
||||
"changedAt":"now","songCount":2},"songs":[],"recommendations":[]},
|
||||
"recommendation":{"videoId":"v1","title":"Pick","artist":"Artist",
|
||||
"state":"added"}}
|
||||
"recommendation":{"source":"deezer","externalId":"v1","title":"Pick",
|
||||
"artist":"Artist","state":"added"}}
|
||||
""".trimIndent(),
|
||||
HttpStatusCode.OK,
|
||||
jsonHeaders,
|
||||
@@ -122,8 +123,8 @@ class ApiClientTest {
|
||||
"""
|
||||
{"detail":{"mood":{"id":"mo-1","name":"Focus","createdAt":"now",
|
||||
"changedAt":"now","songCount":2},"songs":[],"recommendations":[]},
|
||||
"recommendation":{"videoId":"v2","title":"Other","artist":"Artist",
|
||||
"state":"rejected"}}
|
||||
"recommendation":{"source":"deezer","externalId":"v2","title":"Other",
|
||||
"artist":"Artist","state":"rejected"}}
|
||||
""".trimIndent(),
|
||||
HttpStatusCode.OK,
|
||||
jsonHeaders,
|
||||
@@ -223,6 +224,6 @@ class ApiClientTest {
|
||||
storage.write("mood-cache.json", """{"version":1,"songs":[{"id":"old"}]}""")
|
||||
val invalidated = cache.load()
|
||||
assertTrue(invalidated.moods.isEmpty())
|
||||
assertEquals(2, invalidated.version)
|
||||
assertEquals(3, invalidated.version)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user