mirror of https://github.com/readrops/Readrops.git
Fix duplicate items when synchronizing a fever account
This commit is contained in:
parent
57d66b565c
commit
326fdde7eb
|
@ -48,7 +48,7 @@ class FeverDataSource(private val service: FeverService) {
|
||||||
|
|
||||||
if (newItems.isEmpty()) break
|
if (newItems.isEmpty()) break
|
||||||
// always take the lowest id
|
// always take the lowest id
|
||||||
maxId = newItems.last().remoteId!!
|
maxId = newItems.minOfOrNull { it.remoteId!!.toLong() }.toString()
|
||||||
addAll(newItems)
|
addAll(newItems)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ class FeverDataSource(private val service: FeverService) {
|
||||||
|
|
||||||
if (newItems.isEmpty()) break
|
if (newItems.isEmpty()) break
|
||||||
// always take the highest id
|
// always take the highest id
|
||||||
localSinceId = newItems.first().remoteId!!
|
localSinceId = newItems.maxOfOrNull { it.remoteId!!.toLong() }.toString()
|
||||||
addAll(newItems)
|
addAll(newItems)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -229,8 +229,6 @@ class FeverDataSourceTest : KoinTest {
|
||||||
assertEquals(6, result.unreadIds.size)
|
assertEquals(6, result.unreadIds.size)
|
||||||
assertEquals(6, result.starredIds.size)
|
assertEquals(6, result.starredIds.size)
|
||||||
assertEquals(10, result.items.size)
|
assertEquals(10, result.items.size)
|
||||||
assertEquals("5", result.items.first().remoteId)
|
|
||||||
assertEquals("6", result.items.last().remoteId)
|
|
||||||
|
|
||||||
assertEquals("1", firstLastSinceId)
|
assertEquals("1", firstLastSinceId)
|
||||||
assertEquals("5", secondLastSinceId)
|
assertEquals("5", secondLastSinceId)
|
||||||
|
|
|
@ -31,7 +31,7 @@ class FeverItemsAdapterTest {
|
||||||
assertTrue(isStarred)
|
assertTrue(isStarred)
|
||||||
assertTrue(isRead)
|
assertTrue(isRead)
|
||||||
assertNotNull(pubDate)
|
assertNotNull(pubDate)
|
||||||
assertEquals(remoteId, "10")
|
assertEquals(remoteId, "6")
|
||||||
assertEquals(feedRemoteId, "2")
|
assertEquals(feedRemoteId, "2")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"total_items": 10814,
|
"total_items": 10814,
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"id": "5",
|
"id": "3",
|
||||||
"feed_id": 2,
|
"feed_id": 2,
|
||||||
"title": "FreshRSS 1.9.0",
|
"title": "FreshRSS 1.9.0",
|
||||||
"author": "Alkarex",
|
"author": "Alkarex",
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
"created_on_time": 1515697500
|
"created_on_time": 1515697500
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "3",
|
"id": "5",
|
||||||
"feed_id": 2,
|
"feed_id": 2,
|
||||||
"title": "FreshRSS 1.9.0",
|
"title": "FreshRSS 1.9.0",
|
||||||
"author": "Alkarex",
|
"author": "Alkarex",
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"total_items": 10814,
|
"total_items": 10814,
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"id": "10",
|
"id": "6",
|
||||||
"feed_id": 2,
|
"feed_id": 2,
|
||||||
"title": "FreshRSS 1.9.0",
|
"title": "FreshRSS 1.9.0",
|
||||||
"author": "Alkarex",
|
"author": "Alkarex",
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
"created_on_time": 1515697500
|
"created_on_time": 1515697500
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "6",
|
"id": "10",
|
||||||
"feed_id": 2,
|
"feed_id": 2,
|
||||||
"title": "FreshRSS 1.9.0",
|
"title": "FreshRSS 1.9.0",
|
||||||
"author": "Alkarex",
|
"author": "Alkarex",
|
||||||
|
|
Loading…
Reference in New Issue