Fix Nextcloud News item duplicates when synchronizing

This commit is contained in:
Shinokuni 2024-12-01 17:33:09 +01:00
parent 35d3b31c5a
commit 6e1dbc789c
2 changed files with 3 additions and 2 deletions

View File

@ -162,7 +162,7 @@ class NextcloudNewsRepository(
itemsFeedsIds[item.feedRemoteId] = feedId
}
if (!initialSync && feedId > 0 && database.itemDao().itemExists(item.remoteId!!, feedId)) {
if (!initialSync && feedId > 0 && database.itemDao().itemExists(item.remoteId!!, account.id)) {
database.itemDao()
.updateReadAndStarState(item.remoteId!!, item.isRead, item.isStarred)
continue

View File

@ -67,6 +67,7 @@ abstract class ItemDao : BaseDao<Item> {
abstract fun selectFeedUnreadItemsCount(query: SupportSQLiteQuery):
Flow<Map<@MapColumn(columnName = "feed_id") Int, @MapColumn(columnName = "item_count") Int>>
@Query("Select case When :remoteId In (Select Item.remote_id From Item Inner Join Feed on Item.feed_id = Feed.id and account_id = :accountId) Then 1 else 0 end")
@Query("""Select case When Exists(Select 1 From Item Inner Join Feed on Item.feed_id = Feed.id
Where Item.remote_id = :remoteId And account_id = :accountId) Then 1 else 0 end""")
abstract suspend fun itemExists(remoteId: String, accountId: Int): Boolean
}