Fix item not having an id for one item sync result notification case

This commit is contained in:
Shinokuni 2020-03-11 21:15:43 +01:00
parent 67579bb336
commit 2f7fd36511
3 changed files with 12 additions and 7 deletions

View File

@ -56,7 +56,8 @@ class SyncResultAnalyser(val context: Context, private val syncResults: Map<Acco
}
if (syncResult.items.size == 1) {
item = syncResult.items.first()
item = database.itemDao().selectByRemoteId(syncResult.items.first().remoteId,
syncResult.items.first().feedId)
contentText = item.title
} else contentText = context.getString(R.string.new_items, syncResult.items.size.toString())
}

View File

@ -1,5 +1,7 @@
package com.readrops.app.utils
import android.content.Context
import com.readrops.readropsdb.Database
import com.readrops.readropsdb.entities.Item
import com.readrops.readropsdb.entities.account.Account
import com.readrops.readropsdb.entities.account.AccountType
@ -9,17 +11,13 @@ class SyncResultDebugData {
companion object {
fun oneAccountOneFeedOneItem(): Map<Account, SyncResult> {
fun oneAccountOneFeedOneItem(context: Context): Map<Account, SyncResult> {
val account1 = Account().apply {
id = 1
accountType = AccountType.FRESHRSS
}
val item = Item().apply {
id = 1
title = "oneAccountOneFeedOneItem"
feedId = 90
}
val item = Database.getInstance(context).itemDao().select(5362)
return mutableMapOf<Account, SyncResult>().apply {
put(account1, SyncResult().apply { items = mutableListOf(item) })

View File

@ -24,12 +24,18 @@ public interface ItemDao extends BaseDao<Item> {
@RawQuery(observedEntities = {Item.class, Folder.class, Feed.class})
DataSource.Factory<Integer, ItemWithFeed> selectAll(SupportSQLiteQuery query);
@Query("Select * From Item Where id = :itemId")
Item select(int itemId);
@Query("Select case When :guid In (Select guid From Item Inner Join Feed on Item.feed_id = Feed.id and account_id = :accountId) Then 1 else 0 end")
boolean itemExists(String guid, int accountId);
@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(String remoteId, int feedId);
@Query("Select * From Item Where remoteId = :remoteId And feed_id = :feedId")
Item selectByRemoteId(String remoteId, int feedId);
/**
* Set an item read or unread
*