diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt index 31c37b75a..be0f31756 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Context.kt @@ -674,6 +674,8 @@ fun Context.getCachedMedia(path: String, getVideosOnly: Boolean = false, getImag try { if (mediaToDelete.isNotEmpty()) { mediaDB.deleteMedia(*mediaToDelete.toTypedArray()) + val favorites = mediaToDelete.map { getFavoriteFromPath(it.path) } + favoritesDB.deleteFavorites(*favorites.toTypedArray()) } } catch (ignored: Exception) { } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDao.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDao.kt index d835d9f65..8a890e20a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDao.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/interfaces/FavoritesDao.kt @@ -1,9 +1,6 @@ package com.simplemobiletools.gallery.pro.interfaces -import androidx.room.Dao -import androidx.room.Insert -import androidx.room.OnConflictStrategy -import androidx.room.Query +import androidx.room.* import com.simplemobiletools.gallery.pro.models.Favorite @Dao @@ -23,6 +20,9 @@ interface FavoritesDao { @Query("SELECT id FROM favorites WHERE full_path = :path COLLATE NOCASE") fun isFavorite(path: String): Boolean + @Delete + fun deleteFavorites(vararg favorite: Favorite) + @Query("DELETE FROM favorites WHERE full_path = :path COLLATE NOCASE") fun deleteFavoritePath(path: String)