From dd98c7b0a6b71994d06c3785de4492971b664edb Mon Sep 17 00:00:00 2001 From: Shinokuni Date: Wed, 14 Aug 2024 18:58:30 +0200 Subject: [PATCH] Fix getting sinceId after last items call in FeverDataSource --- .../java/com/readrops/api/services/fever/FeverDataSource.kt | 2 +- .../java/com/readrops/api/services/fever/FeverDataSourceTest.kt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) 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 7aa0046b..bf5fd1c3 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 @@ -82,7 +82,7 @@ class FeverDataSource(private val service: FeverService) { } sinceId = if (items.isNotEmpty()) { - items.first().remoteId!!.toLong() + items.maxOfOrNull { it.remoteId!!.toLong() }!! } else { localSinceId.toLong() } diff --git a/api/src/test/java/com/readrops/api/services/fever/FeverDataSourceTest.kt b/api/src/test/java/com/readrops/api/services/fever/FeverDataSourceTest.kt index 0b977929..38bd11bd 100644 --- a/api/src/test/java/com/readrops/api/services/fever/FeverDataSourceTest.kt +++ b/api/src/test/java/com/readrops/api/services/fever/FeverDataSourceTest.kt @@ -157,6 +157,7 @@ class FeverDataSourceTest : KoinTest { assertEquals(6, result.starredIds.size) assertEquals(10, result.items.size) assertEquals(10, result.items.size) + assertEquals(1564058340320135, result.sinceId) assertEquals("1564058340320135", firstMaxId) assertEquals("6", secondMaxId) @@ -229,6 +230,7 @@ class FeverDataSourceTest : KoinTest { assertEquals(6, result.unreadIds.size) assertEquals(6, result.starredIds.size) assertEquals(10, result.items.size) + assertEquals(10, result.sinceId) assertEquals("1", firstLastSinceId) assertEquals("5", secondLastSinceId)