fixed some glitches with favorites un/marking

This commit is contained in:
tibbi 2021-10-21 13:59:54 +02:00
parent 50e6b98d09
commit 811d5e88c5
2 changed files with 10 additions and 2 deletions

View file

@ -611,8 +611,13 @@ class MediaActivity : SimpleActivity(), MediaOperationsListener {
val newMedia = it val newMedia = it
try { try {
gotMedia(newMedia, false) gotMedia(newMedia, false)
oldMedia.filter { !newMedia.contains(it) }.mapNotNull { it as? Medium }.filter { !getDoesFilePathExist(it.path) }.forEach { oldMedia.filter { !newMedia.contains(it) }.mapNotNull { it as? Medium }.forEach {
mediaDB.deleteMediumPath(it.path) if (!getDoesFilePathExist(it.path)) {
mediaDB.deleteMediumPath(it.path)
} else if (mPath == FAVORITES) {
favoritesDB.deleteFavoritePath(it.path)
mediaDB.updateFavorite(it.path, false)
}
} }
} catch (e: Exception) { } catch (e: Exception) {
} }

View file

@ -42,6 +42,9 @@ interface MediumDao {
@Query("UPDATE media SET date_taken = :dateTaken WHERE full_path = :path COLLATE NOCASE") @Query("UPDATE media SET date_taken = :dateTaken WHERE full_path = :path COLLATE NOCASE")
fun updateFavoriteDateTaken(path: String, dateTaken: Long) fun updateFavoriteDateTaken(path: String, dateTaken: Long)
@Query("UPDATE media SET is_favorite = :isFavorite WHERE full_path = :path COLLATE NOCASE")
fun updateFavorite(path: String, isFavorite: Boolean)
@Query("UPDATE media SET is_favorite = 0") @Query("UPDATE media SET is_favorite = 0")
fun clearFavorites() fun clearFavorites()