From cbc9d8b3c2c7802d4f43d3d5baebde05cf81c3ea Mon Sep 17 00:00:00 2001 From: Shinokuni Date: Fri, 16 Aug 2024 14:43:51 +0200 Subject: [PATCH] Fever: do not trust provider ordering and always check for the max instead of the first element --- .../java/com/readrops/api/services/fever/FeverDataSource.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/com/readrops/api/services/fever/FeverDataSource.kt b/api/src/main/java/com/readrops/api/services/fever/FeverDataSource.kt index 2e4c791d..6c641096 100644 --- a/api/src/main/java/com/readrops/api/services/fever/FeverDataSource.kt +++ b/api/src/main/java/com/readrops/api/services/fever/FeverDataSource.kt @@ -41,7 +41,7 @@ class FeverDataSource(private val service: FeverService) { .reversed() .take(MAX_ITEMS_IDS) - var maxId = unreadIds.first() + var maxId = unreadIds.maxOfOrNull { it } items = buildList { for (index in 0 until INITIAL_SYNC_ITEMS_REQUESTS_COUNT) { val newItems = service.getItems(body, maxId, null) @@ -53,7 +53,7 @@ class FeverDataSource(private val service: FeverService) { } } - sinceId = unreadIds.first().toLong() + sinceId = unreadIds.maxOfOrNull { it.toLong() } ?: 0 }, async { starredIds = service.getStarredItemsIds(body) }, async { favicons = service.getFavicons(body) }