Delete cache when a song is deleted from the database

This commit is contained in:
vfsfitvnm
2022-06-12 15:16:14 +02:00
parent aa27e14e97
commit be8b91b3b0
2 changed files with 12 additions and 0 deletions

View File

@@ -25,6 +25,7 @@ import it.vfsfitvnm.vimusic.internal
import it.vfsfitvnm.vimusic.models.Playlist
import it.vfsfitvnm.vimusic.models.SongInPlaylist
import it.vfsfitvnm.vimusic.models.SongWithInfo
import it.vfsfitvnm.vimusic.services.DeleteSongCacheCommand
import it.vfsfitvnm.vimusic.services.StartRadioCommand
import it.vfsfitvnm.vimusic.services.StopRadioCommand
import it.vfsfitvnm.vimusic.ui.components.LocalMenuState
@@ -65,6 +66,8 @@ fun InHistoryMediaItemMenu(
// https://issuetracker.google.com/issues/226410236
onDismiss: () -> Unit = LocalMenuState.current.let { it::hide }
) {
val mediaController = LocalYoutubePlayer.current?.mediaController
val coroutineScope = rememberCoroutineScope()
var isDeletingFromDatabase by remember {
@@ -79,6 +82,7 @@ fun InHistoryMediaItemMenu(
},
onConfirm = {
onDismiss()
mediaController?.sendCustomCommand(DeleteSongCacheCommand, bundleOf("videoId" to song.song.id))
coroutineScope.launch(Dispatchers.IO) {
Database.delete(song.song)
}