fix unselecting invalid favorite items

This commit is contained in:
tibbi 2020-01-27 14:47:17 +01:00
parent 4d7e95d72a
commit 86db0b8f19
2 changed files with 4 additions and 5 deletions

View file

@ -674,8 +674,10 @@ 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())
mediaToDelete.filter { it.isFavorite }.forEach {
favoritesDB.deleteFavoritePath(it.path)
}
}
} catch (ignored: Exception) {
}

View file

@ -23,9 +23,6 @@ interface FavoritesDao {
@Query("UPDATE OR REPLACE favorites SET filename = :newFilename, full_path = :newFullPath, parent_path = :newParentPath WHERE full_path = :oldPath COLLATE NOCASE")
fun updateFavorite(newFilename: String, newFullPath: String, newParentPath: String, oldPath: String)
@Delete
fun deleteFavorites(vararg favorite: Favorite)
@Query("DELETE FROM favorites WHERE full_path = :path COLLATE NOCASE")
fun deleteFavoritePath(path: String)