fix a rare glitch with events being duplicate after refetching at lists

This commit is contained in:
tibbi 2021-11-21 20:09:18 +01:00
parent 6679858964
commit 69683a857a
1 changed files with 12 additions and 2 deletions

View File

@ -177,7 +177,12 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
val oldMinFetchedTS = minFetchedTS - 1
minFetchedTS -= FETCH_INTERVAL
requireContext().eventsHelper.getEvents(minFetchedTS, oldMinFetchedTS) {
mEvents.addAll(0, it)
it.forEach { event ->
if (mEvents.firstOrNull { it.id == event.id && it.startTS == event.startTS } == null) {
mEvents.add(0, event)
}
}
receivedEvents(mEvents, UPDATE_TOP)
}
}
@ -186,7 +191,12 @@ class EventListFragment : MyFragmentHolder(), RefreshRecyclerViewListener {
val oldMaxFetchedTS = maxFetchedTS + 1
maxFetchedTS += FETCH_INTERVAL
requireContext().eventsHelper.getEvents(oldMaxFetchedTS, maxFetchedTS) {
mEvents.addAll(it)
it.forEach { event ->
if (mEvents.firstOrNull { it.id == event.id && it.startTS == event.startTS } == null) {
mEvents.add(0, event)
}
}
receivedEvents(mEvents, UPDATE_BOTTOM)
}
}