From 1db7ff3f99d843a7b6b2761799cea1501826e5e0 Mon Sep 17 00:00:00 2001 From: Malopieds Date: Fri, 5 Apr 2024 15:19:37 +0200 Subject: [PATCH] feat(keep_listening): fix for #42 --- .../java/com/zionhuang/music/viewmodels/HomeViewModel.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/zionhuang/music/viewmodels/HomeViewModel.kt b/app/src/main/java/com/zionhuang/music/viewmodels/HomeViewModel.kt index ff599e5a0..fcb5e1d52 100644 --- a/app/src/main/java/com/zionhuang/music/viewmodels/HomeViewModel.kt +++ b/app/src/main/java/com/zionhuang/music/viewmodels/HomeViewModel.kt @@ -54,7 +54,14 @@ class HomeViewModel @Inject constructor( private suspend fun load() { quickPicks.value = database.quickPicks().first().shuffled().take(20) - keepListeningArtists.value = database.mostPlayedArtists(System.currentTimeMillis() - 86400000 * 7 * 2).first().shuffled().take(5) + val artists = database.mostPlayedArtists(System.currentTimeMillis() - 86400000 * 7 * 2).first().shuffled().take(5) + val filteredArtists = mutableListOf() + artists.forEach { + if (it.artist.isYouTubeArtist){ + filteredArtists.add(it) + } + } + keepListeningArtists.value = filteredArtists keepListeningAlbums.value = database.getRecommendationAlbum(limit = 8, offset = 2).first().shuffled().take(5) keepListeningSongs.value = database.mostPlayedSongs(System.currentTimeMillis() - 86400000 * 7 * 2, limit = 15, offset = 5).first().shuffled().take(10) val listenAgainBuilder = mutableListOf()