Fix favourites adding/removing
This commit is contained in:
@@ -85,7 +85,7 @@ abstract class FavouritesDao {
|
|||||||
@Query("SELECT DISTINCT category_id FROM favourites WHERE manga_id = :id AND deleted_at = 0")
|
@Query("SELECT DISTINCT category_id FROM favourites WHERE manga_id = :id AND deleted_at = 0")
|
||||||
abstract fun observeIds(id: Long): Flow<List<Long>>
|
abstract fun observeIds(id: Long): Flow<List<Long>>
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.IGNORE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
abstract suspend fun insert(favourite: FavouriteEntity)
|
abstract suspend fun insert(favourite: FavouriteEntity)
|
||||||
|
|
||||||
@Update
|
@Update
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ class FavouritesRepository(
|
|||||||
suspend fun removeFromFavourites(ids: Collection<Long>): ReversibleHandle {
|
suspend fun removeFromFavourites(ids: Collection<Long>): ReversibleHandle {
|
||||||
db.withTransaction {
|
db.withTransaction {
|
||||||
for (id in ids) {
|
for (id in ids) {
|
||||||
db.favouritesDao.delete(id)
|
db.favouritesDao.delete(mangaId = id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ReversibleHandle { recoverToFavourites(ids) }
|
return ReversibleHandle { recoverToFavourites(ids) }
|
||||||
@@ -163,7 +163,7 @@ class FavouritesRepository(
|
|||||||
suspend fun removeFromCategory(categoryId: Long, ids: Collection<Long>): ReversibleHandle {
|
suspend fun removeFromCategory(categoryId: Long, ids: Collection<Long>): ReversibleHandle {
|
||||||
db.withTransaction {
|
db.withTransaction {
|
||||||
for (id in ids) {
|
for (id in ids) {
|
||||||
db.favouritesDao.delete(categoryId, id)
|
db.favouritesDao.delete(categoryId = categoryId, mangaId = id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ReversibleHandle { recoverToCategory(categoryId, ids) }
|
return ReversibleHandle { recoverToCategory(categoryId, ids) }
|
||||||
|
|||||||
Reference in New Issue
Block a user