Check item remoteId presence with its foreign feedId

This commit is contained in:
Shinokuni 2019-06-14 14:52:03 +02:00
parent 9cb3c14e40
commit 65c7141c29
2 changed files with 7 additions and 5 deletions

View File

@ -25,8 +25,8 @@ public interface ItemDao {
@Query("Select case When :guid In (Select guid from Item) Then 'true' else 'false' end") @Query("Select case When :guid In (Select guid from Item) Then 'true' else 'false' end")
String guidExist(String guid); String guidExist(String guid);
@Query("Select case When :remoteId In (Select remoteId from Item) Then 1 else 0 end") @Query("Select case When :remoteId In (Select remoteId from Item) And :feedId In (Select feed_id From Item) Then 1 else 0 end")
boolean remoteItemExists(int remoteId); boolean remoteItemExists(int remoteId, int feedId);
@Insert @Insert
long insert(Item item); long insert(Item item);

View File

@ -192,12 +192,14 @@ public class NextNewsRepository extends ARepository {
for (NextNewsItem nextNewsItem : items) { for (NextNewsItem nextNewsItem : items) {
if (!initialSync) { Feed feed = database.feedDao().getFeedByRemoteId(nextNewsItem.getFeedId(), account.getId());
if (database.itemDao().remoteItemExists(nextNewsItem.getId()))
if (!initialSync && feed != null) {
if (database.itemDao().remoteItemExists(nextNewsItem.getId(), feed.getId()))
break; break;
} }
Feed feed = database.feedDao().getFeedByRemoteId(nextNewsItem.getFeedId(), account.getId());
Item item = ItemMatcher.nextNewsItemToItem(nextNewsItem, feed); Item item = ItemMatcher.nextNewsItemToItem(nextNewsItem, feed);
item.setReadTime(Utils.readTimeFromString(item.getContent())); item.setReadTime(Utils.readTimeFromString(item.getContent()));