Unverified Commit 0e0cfaba authored by Benoît Marty's avatar Benoît Marty Committed by GitHub
Browse files

Merge pull request #3308 from vector-im/feature/fga/fix_timeline_read_marker

Fix read marker visibility/position when filtering some events
parents 7ec44a55 525cd3ed
...@@ -24,6 +24,7 @@ Bugfix 🐛: ...@@ -24,6 +24,7 @@ Bugfix 🐛:
- Fix read marker not updating automatically (#3267) - Fix read marker not updating automatically (#3267)
- Sent video does not contains duration (#3272) - Sent video does not contains duration (#3272)
- Properly clean the back stack if the user cancel registration when waiting for email validation - Properly clean the back stack if the user cancel registration when waiting for email validation
- Fix read marker visibility/position when filtering some events
- Fix user invitation in case of restricted profile api (#3306) - Fix user invitation in case of restricted profile api (#3306)
Translations 🗣: Translations 🗣:
......
...@@ -62,6 +62,7 @@ class TimelineControllerInterceptorHelper(private val positionOfReadMarker: KMut ...@@ -62,6 +62,7 @@ class TimelineControllerInterceptorHelper(private val positionOfReadMarker: KMut
val firstUnreadEventId = (unreadState as? UnreadState.HasUnread)?.firstUnreadEventId val firstUnreadEventId = (unreadState as? UnreadState.HasUnread)?.firstUnreadEventId
var atLeastOneVisibleItemSinceLastDaySeparator = false var atLeastOneVisibleItemSinceLastDaySeparator = false
var atLeastOneVisibleItemsBeforeReadMarker = false var atLeastOneVisibleItemsBeforeReadMarker = false
var appendReadMarker = false
// Then iterate on models so we have the exact positions in the adapter // Then iterate on models so we have the exact positions in the adapter
modelsIterator.forEach { epoxyModel -> modelsIterator.forEach { epoxyModel ->
...@@ -72,11 +73,7 @@ class TimelineControllerInterceptorHelper(private val positionOfReadMarker: KMut ...@@ -72,11 +73,7 @@ class TimelineControllerInterceptorHelper(private val positionOfReadMarker: KMut
} }
epoxyModel.getEventIds().forEach { eventId -> epoxyModel.getEventIds().forEach { eventId ->
adapterPositionMapping[eventId] = index adapterPositionMapping[eventId] = index
if (epoxyModel.canAppendReadMarker() && eventId == firstUnreadEventId && atLeastOneVisibleItemsBeforeReadMarker) { appendReadMarker = epoxyModel.canAppendReadMarker() && eventId == firstUnreadEventId && atLeastOneVisibleItemsBeforeReadMarker
modelsIterator.addReadMarkerItem(callback)
index++
positionOfReadMarker.set(index)
}
} }
} }
if (epoxyModel is DaySeparatorItem) { if (epoxyModel is DaySeparatorItem) {
...@@ -91,6 +88,12 @@ class TimelineControllerInterceptorHelper(private val positionOfReadMarker: KMut ...@@ -91,6 +88,12 @@ class TimelineControllerInterceptorHelper(private val positionOfReadMarker: KMut
atLeastOneVisibleItemSinceLastDaySeparator = true atLeastOneVisibleItemSinceLastDaySeparator = true
} }
} }
if (appendReadMarker) {
modelsIterator.addReadMarkerItem(callback)
index++
positionOfReadMarker.set(index)
appendReadMarker = false
}
index++ index++
} }
previousModelsSize = models.size previousModelsSize = models.size
...@@ -103,8 +106,6 @@ class TimelineControllerInterceptorHelper(private val positionOfReadMarker: KMut ...@@ -103,8 +106,6 @@ class TimelineControllerInterceptorHelper(private val positionOfReadMarker: KMut
it.setOnVisibilityStateChanged(ReadMarkerVisibilityStateChangedListener(callback)) it.setOnVisibilityStateChanged(ReadMarkerVisibilityStateChangedListener(callback))
} }
add(readMarker) add(readMarker)
// Use next as we still have some process to do before the next iterator loop
next()
} }
private fun MutableListIterator<EpoxyModel<*>>.removeCallItemIfNeeded( private fun MutableListIterator<EpoxyModel<*>>.removeCallItemIfNeeded(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment