Append older articles fetched

This commit is contained in:
davide 2022-08-14 12:39:20 +02:00
parent 88c5c6ff4b
commit 22f0ff664c

View File

@ -80,15 +80,15 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet
searchFilter) searchFilter)
if (fetchedItems != null) { if (fetchedItems != null) {
items = ArrayList(fetchedItems) appendItems(fetchedItems)
} }
return items return items
} }
private fun storeItems(fetchedItems: List<SelfossModel.Item>) { private fun appendItems(fetchedItems: List<SelfossModel.Item>) {
// TODO: Store in DB // TODO: Store in DB if enabled by user
val fetchedIDS = fetchedItems.map { it.id } val fetchedIDS = fetchedItems.map { it.id }
val tmpItems = ArrayList(items) val tmpItems = items
tmpItems.removeAll{ it.id in fetchedIDS } tmpItems.removeAll{ it.id in fetchedIDS }
tmpItems.addAll(fetchedItems) tmpItems.addAll(fetchedItems)
sortItems(tmpItems) sortItems(tmpItems)
@ -100,7 +100,7 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet
} }
private fun filterSelectedItems(items: ArrayList<SelfossModel.Item>): ArrayList<SelfossModel.Item> { private fun filterSelectedItems(items: ArrayList<SelfossModel.Item>): ArrayList<SelfossModel.Item> {
val tmpItems = ArrayList(items) val tmpItems = items
if (displayedItems == "unread") { if (displayedItems == "unread") {
tmpItems.removeAll { !it.unread } tmpItems.removeAll { !it.unread }
} else if (displayedItems == "starred") { } else if (displayedItems == "starred") {