From 22f0ff664c1104ebcb21d278859ffdbeae309ff5 Mon Sep 17 00:00:00 2001 From: davide Date: Sun, 14 Aug 2022 12:39:20 +0200 Subject: [PATCH] Append older articles fetched --- .../readerforselfossv2/repository/RepositoryImpl.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt index abc6e8e..56fdfac 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt @@ -80,15 +80,15 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet searchFilter) if (fetchedItems != null) { - items = ArrayList(fetchedItems) + appendItems(fetchedItems) } return items } - private fun storeItems(fetchedItems: List) { - // TODO: Store in DB + private fun appendItems(fetchedItems: List) { + // TODO: Store in DB if enabled by user val fetchedIDS = fetchedItems.map { it.id } - val tmpItems = ArrayList(items) + val tmpItems = items tmpItems.removeAll{ it.id in fetchedIDS } tmpItems.addAll(fetchedItems) sortItems(tmpItems) @@ -100,7 +100,7 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet } private fun filterSelectedItems(items: ArrayList): ArrayList { - val tmpItems = ArrayList(items) + val tmpItems = items if (displayedItems == "unread") { tmpItems.removeAll { !it.unread } } else if (displayedItems == "starred") {