Fever: do not trust provider ordering and always check for the max instead of the first element

This commit is contained in:
Shinokuni 2024-08-16 14:43:51 +02:00
parent 345c4a2bd7
commit cbc9d8b3c2
1 changed files with 2 additions and 2 deletions

View File

@ -41,7 +41,7 @@ class FeverDataSource(private val service: FeverService) {
.reversed() .reversed()
.take(MAX_ITEMS_IDS) .take(MAX_ITEMS_IDS)
var maxId = unreadIds.first() var maxId = unreadIds.maxOfOrNull { it }
items = buildList { items = buildList {
for (index in 0 until INITIAL_SYNC_ITEMS_REQUESTS_COUNT) { for (index in 0 until INITIAL_SYNC_ITEMS_REQUESTS_COUNT) {
val newItems = service.getItems(body, maxId, null) 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 { starredIds = service.getStarredItemsIds(body) },
async { favicons = service.getFavicons(body) } async { favicons = service.getFavicons(body) }