mirror of https://github.com/readrops/Readrops.git
Fix item duplicates when getting last modified items
This commit is contained in:
parent
73b4b8e4d3
commit
64d3f384be
|
@ -95,7 +95,7 @@ public class NextNewsRepository extends ARepository {
|
|||
insertFeeds(syncResult.getFeeds(), account);
|
||||
timings.addSplit("insert feeds");
|
||||
|
||||
insertItems(syncResult.getItems(), account);
|
||||
insertItems(syncResult.getItems(), account, syncType == NextNewsAPI.SyncType.INITIAL_SYNC);
|
||||
timings.addSplit("insert items");
|
||||
timings.dumpToLog();
|
||||
|
||||
|
@ -187,17 +187,22 @@ public class NextNewsRepository extends ARepository {
|
|||
database.folderDao().insert(newFolders);
|
||||
}
|
||||
|
||||
private void insertItems(List<NextNewsItem> items, Account account) {
|
||||
private void insertItems(List<NextNewsItem> items, Account account, boolean initialSync) {
|
||||
List<Item> newItems = new ArrayList<>();
|
||||
|
||||
for (NextNewsItem nextNewsItem : items) {
|
||||
|
||||
if (!initialSync) {
|
||||
if (database.itemDao().remoteItemExists(nextNewsItem.getId()))
|
||||
break;
|
||||
}
|
||||
|
||||
Feed feed = database.feedDao().getFeedByRemoteId(nextNewsItem.getFeedId(), account.getId());
|
||||
Item item = ItemMatcher.nextNewsItemToItem(nextNewsItem, feed);
|
||||
|
||||
item.setReadTime(Utils.readTimeFromString(item.getContent()));
|
||||
|
||||
newItems.add(item);
|
||||
|
||||
}
|
||||
|
||||
Collections.sort(newItems, Item::compareTo);
|
||||
|
|
Loading…
Reference in New Issue