Fix ui echo isues
This commit is contained in:
parent
f127a75e38
commit
9ec68fa5be
|
@ -167,11 +167,14 @@ internal class DefaultTimeline(
|
||||||
val roomEntity = RoomEntity.where(realm, roomId = roomId).findFirst()
|
val roomEntity = RoomEntity.where(realm, roomId = roomId).findFirst()
|
||||||
?: throw IllegalStateException("Can't open a timeline without a room")
|
?: throw IllegalStateException("Can't open a timeline without a room")
|
||||||
|
|
||||||
sendingEvents = roomEntity.sendingTimelineEvents.where().filterEventsWithSettings().findAll()
|
// We don't want to filter here because some sending events that are not displayed
|
||||||
|
// are still used for ui echo (relation like reaction)
|
||||||
|
sendingEvents = roomEntity.sendingTimelineEvents.where()/*.filterEventsWithSettings()*/.findAll()
|
||||||
sendingEvents.addChangeListener { events ->
|
sendingEvents.addChangeListener { events ->
|
||||||
uiEchoManager.sentEventsUpdated(events)
|
uiEchoManager.sentEventsUpdated(events)
|
||||||
postSnapshot()
|
postSnapshot()
|
||||||
}
|
}
|
||||||
|
|
||||||
nonFilteredEvents = buildEventQuery(realm).sort(TimelineEventEntityFields.DISPLAY_INDEX, Sort.DESCENDING).findAll()
|
nonFilteredEvents = buildEventQuery(realm).sort(TimelineEventEntityFields.DISPLAY_INDEX, Sort.DESCENDING).findAll()
|
||||||
filteredEvents = nonFilteredEvents.where()
|
filteredEvents = nonFilteredEvents.where()
|
||||||
.filterEventsWithSettings()
|
.filterEventsWithSettings()
|
||||||
|
@ -410,11 +413,14 @@ internal class DefaultTimeline(
|
||||||
val builtSendingEvents = ArrayList<TimelineEvent>()
|
val builtSendingEvents = ArrayList<TimelineEvent>()
|
||||||
if (hasReachedEnd(Timeline.Direction.FORWARDS) && !hasMoreInCache(Timeline.Direction.FORWARDS)) {
|
if (hasReachedEnd(Timeline.Direction.FORWARDS) && !hasMoreInCache(Timeline.Direction.FORWARDS)) {
|
||||||
builtSendingEvents.addAll(uiEchoManager.getInMemorySendingEvents().filterEventsWithSettings())
|
builtSendingEvents.addAll(uiEchoManager.getInMemorySendingEvents().filterEventsWithSettings())
|
||||||
sendingEvents.forEach { timelineEventEntity ->
|
sendingEvents
|
||||||
if (builtSendingEvents.find { it.eventId == timelineEventEntity.eventId } == null) {
|
.map { timelineEventMapper.map(it) }
|
||||||
val element = timelineEventMapper.map(timelineEventEntity)
|
// Filter out sending event that are not displayable!
|
||||||
uiEchoManager.updateSentStateWithUiEcho(element)
|
.filterEventsWithSettings()
|
||||||
builtSendingEvents.add(element)
|
.forEach { timelineEvent ->
|
||||||
|
if (builtSendingEvents.find { it.eventId == timelineEvent.eventId } == null) {
|
||||||
|
uiEchoManager.updateSentStateWithUiEcho(timelineEvent)
|
||||||
|
builtSendingEvents.add(timelineEvent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -782,8 +788,8 @@ internal class DefaultTimeline(
|
||||||
val filterType = !settings.filters.filterTypes || settings.filters.allowedTypes.contains(it.root.type)
|
val filterType = !settings.filters.filterTypes || settings.filters.allowedTypes.contains(it.root.type)
|
||||||
if (!filterType) return@filter false
|
if (!filterType) return@filter false
|
||||||
|
|
||||||
val filterEdits = if (settings.filters.filterEdits && it.root.type == EventType.MESSAGE) {
|
val filterEdits = if (settings.filters.filterEdits && it.root.getClearType() == EventType.MESSAGE) {
|
||||||
val messageContent = it.root.content.toModel<MessageContent>()
|
val messageContent = it.root.getClearContent().toModel<MessageContent>()
|
||||||
messageContent?.relatesTo?.type != RelationType.REPLACE && messageContent?.relatesTo?.type != RelationType.RESPONSE
|
messageContent?.relatesTo?.type != RelationType.REPLACE && messageContent?.relatesTo?.type != RelationType.RESPONSE
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
|
@ -831,8 +837,13 @@ internal class DefaultTimeline(
|
||||||
inMemorySendingStates.keys.removeAll { key ->
|
inMemorySendingStates.keys.removeAll { key ->
|
||||||
events.find { it.eventId == key } == null
|
events.find { it.eventId == key } == null
|
||||||
}
|
}
|
||||||
inMemoryReactions.keys.removeAll { key ->
|
|
||||||
events.find { it.eventId == key } == null
|
inMemoryReactions.forEach { (_, uiEchoData) ->
|
||||||
|
uiEchoData.removeAll { data ->
|
||||||
|
// I remove the uiEcho, when the related event is not anymore in the sending list
|
||||||
|
// (means that it is synced)!
|
||||||
|
events.find { it.eventId == data.localEchoId } == null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -896,6 +907,7 @@ internal class DefaultTimeline(
|
||||||
relatedEventID
|
relatedEventID
|
||||||
)
|
)
|
||||||
val updateReactions = existingAnnotationSummary.reactionsSummary.toMutableList()
|
val updateReactions = existingAnnotationSummary.reactionsSummary.toMutableList()
|
||||||
|
|
||||||
contents.forEach { uiEchoReaction ->
|
contents.forEach { uiEchoReaction ->
|
||||||
val existing = updateReactions.firstOrNull { it.key == uiEchoReaction.reaction }
|
val existing = updateReactions.firstOrNull { it.key == uiEchoReaction.reaction }
|
||||||
if (existing == null) {
|
if (existing == null) {
|
||||||
|
|
Loading…
Reference in New Issue