Shuffle all now queues only downloaded tracks in offline mode, matching how a mood falls back to downloads, and says so when there are none.
This commit is contained in:
1 parent
c7c1d59b70
commit
2234192dc7
1 file changed
+12
-3
@@ -480,10 +480,19 @@ class AppStore(
|
|||||||
*/
|
*/
|
||||||
fun playAll(shuffled: Boolean = true) {
|
fun playAll(shuffled: Boolean = true) {
|
||||||
val state = _state.value
|
val state = _state.value
|
||||||
if (state.library.isEmpty()) {
|
val songs = if (state.offline) {
|
||||||
|
state.library.filter { it.id in state.downloads }
|
||||||
|
} else {
|
||||||
|
state.library
|
||||||
|
}
|
||||||
|
if (songs.isEmpty()) {
|
||||||
_state.update {
|
_state.update {
|
||||||
it.copy(
|
it.copy(
|
||||||
message = "The library is empty. Scan a music folder first.",
|
message = if (state.offline) {
|
||||||
|
"No downloaded tracks available offline."
|
||||||
|
} else {
|
||||||
|
"The library is empty. Scan a music folder first."
|
||||||
|
},
|
||||||
messageIsError = true,
|
messageIsError = true,
|
||||||
messageId = it.messageId + 1,
|
messageId = it.messageId + 1,
|
||||||
)
|
)
|
||||||
@@ -492,7 +501,7 @@ class AppStore(
|
|||||||
}
|
}
|
||||||
scope.launch {
|
scope.launch {
|
||||||
state.session?.let { runCatching { api.closeSession(it.id) } }
|
state.session?.let { runCatching { api.closeSession(it.id) } }
|
||||||
val queue = if (shuffled) state.library.shuffled(Random.Default) else state.library
|
val queue = if (shuffled) songs.shuffled(Random.Default) else songs
|
||||||
_state.update { it.copy(session = null, queue = queue) }
|
_state.update { it.copy(session = null, queue = queue) }
|
||||||
playNext()
|
playNext()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user