From f4a55ff2ad02e3c1fc92b171facb317b380940f4 Mon Sep 17 00:00:00 2001 From: vfsfitvnm Date: Wed, 26 Oct 2022 12:40:13 +0200 Subject: [PATCH] Clear SongAlbumMaps before upserting new album data --- app/src/main/kotlin/it/vfsfitvnm/vimusic/Database.kt | 3 +++ .../it/vfsfitvnm/vimusic/ui/screens/album/AlbumScreen.kt | 2 ++ 2 files changed, 5 insertions(+) diff --git a/app/src/main/kotlin/it/vfsfitvnm/vimusic/Database.kt b/app/src/main/kotlin/it/vfsfitvnm/vimusic/Database.kt index c10ace9..e13bcbb 100644 --- a/app/src/main/kotlin/it/vfsfitvnm/vimusic/Database.kt +++ b/app/src/main/kotlin/it/vfsfitvnm/vimusic/Database.kt @@ -305,6 +305,9 @@ interface Database { @Query("DELETE FROM SongPlaylistMap WHERE playlistId = :id") fun clearPlaylist(id: Long) + @Query("DELETE FROM SongAlbumMap WHERE albumId = :id") + fun clearAlbum(id: String) + @Query("SELECT loudnessDb FROM Format WHERE songId = :songId") fun loudnessDb(songId: String): Flow diff --git a/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/album/AlbumScreen.kt b/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/album/AlbumScreen.kt index 2539a99..bed087f 100644 --- a/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/album/AlbumScreen.kt +++ b/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/album/AlbumScreen.kt @@ -79,6 +79,8 @@ fun AlbumScreen(browseId: String) { ?.onSuccess { currentAlbumPage -> albumPage = currentAlbumPage + Database.clearAlbum(browseId) + Database.upsert( Album( id = browseId,