Set modified items read state for Nextcloud news sync

This commit is contained in:
Shinokuni 2019-10-18 22:07:24 +02:00
parent ae1d9f056a
commit 49cafbb062
1 changed files with 7 additions and 5 deletions

View File

@ -300,8 +300,8 @@ public class NextNewsRepository extends ARepository<NextNewsAPI> {
for (NextNewsItem nextNewsItem : items) { for (NextNewsItem nextNewsItem : items) {
int feedId = database.feedDao().getFeedIdByRemoteId(String.valueOf(nextNewsItem.getFeedId()), account.getId()); int feedId = database.feedDao().getFeedIdByRemoteId(String.valueOf(nextNewsItem.getFeedId()), account.getId());
if (!initialSync && feedId > 0) { if (!initialSync && feedId > 0 && database.itemDao().remoteItemExists(String.valueOf(nextNewsItem.getId()), feedId)) {
if (database.itemDao().remoteItemExists(String.valueOf(nextNewsItem.getId()), feedId)) database.itemDao().setReadState(String.valueOf(nextNewsItem.getId()), !nextNewsItem.isUnread());
break; break;
} }
@ -311,7 +311,9 @@ public class NextNewsRepository extends ARepository<NextNewsAPI> {
newItems.add(item); newItems.add(item);
} }
if (!newItems.isEmpty()) {
Collections.sort(newItems, Item::compareTo); Collections.sort(newItems, Item::compareTo);
database.itemDao().insert(newItems); database.itemDao().insert(newItems);
} }
} }
}