Skip to content

Commit

Permalink
fix(homeScreen): implem of a fix for z-huang#9
Browse files Browse the repository at this point in the history
  • Loading branch information
Malopieds committed Mar 22, 2024
1 parent 7045950 commit 11f1ed5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app/src/main/java/com/zionhuang/music/viewmodels/HomeViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,25 @@ class HomeViewModel @Inject constructor(
}

init {
viewModelScope.launch(Dispatchers.IO) {
val mostPlayedArtists = database.mostPlayedArtists(System.currentTimeMillis() - 86400000 * 7 * 2)
viewModelScope.launch {
mostPlayedArtists.collect { artists ->
artists
.map { it.artist }
.filter {
it.thumbnailUrl == null
}
.forEach { artist ->
YouTube.artist(artist.id).onSuccess { artistPage ->
database.query {
update(artist, artistPage)
}
}
}
}
}
}
viewModelScope.launch(Dispatchers.IO) {
isRefreshing.value = true
load()
Expand Down

0 comments on commit 11f1ed5

Please # to comment.