Cleanup
This commit is contained in:
parent
33eed443d9
commit
66aa9cd888
@ -162,7 +162,7 @@ internal class DefaultTimeline(
|
|||||||
// are still used for ui echo (relation like reaction)
|
// are still used for ui echo (relation like reaction)
|
||||||
sendingEvents = roomEntity.sendingTimelineEvents.where()/*.filterEventsWithSettings()*/.findAll()
|
sendingEvents = roomEntity.sendingTimelineEvents.where()/*.filterEventsWithSettings()*/.findAll()
|
||||||
sendingEvents.addChangeListener { events ->
|
sendingEvents.addChangeListener { events ->
|
||||||
uiEchoManager.sentEventsUpdated(events)
|
uiEchoManager.onSentEventsInDatabase(events.map { it.eventId })
|
||||||
postSnapshot()
|
postSnapshot()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,7 +339,7 @@ internal class DefaultTimeline(
|
|||||||
|
|
||||||
override fun onLocalEchoUpdated(roomId: String, eventId: String, sendState: SendState) {
|
override fun onLocalEchoUpdated(roomId: String, eventId: String, sendState: SendState) {
|
||||||
if (roomId != this.roomId || !isLive) return
|
if (roomId != this.roomId || !isLive) return
|
||||||
if (uiEchoManager.onLocalEchoUpdated(eventId, sendState)) {
|
if (uiEchoManager.onSendStateUpdated(eventId, sendState)) {
|
||||||
postSnapshot()
|
postSnapshot()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.matrix.android.sdk.internal.session.room.timeline
|
package org.matrix.android.sdk.internal.session.room.timeline
|
||||||
|
|
||||||
import io.realm.RealmResults
|
|
||||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||||
import org.matrix.android.sdk.api.session.events.model.RelationType
|
import org.matrix.android.sdk.api.session.events.model.RelationType
|
||||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||||
@ -26,7 +25,6 @@ import org.matrix.android.sdk.api.session.room.model.relation.ReactionContent
|
|||||||
import org.matrix.android.sdk.api.session.room.send.SendState
|
import org.matrix.android.sdk.api.session.room.send.SendState
|
||||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
|
||||||
import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
|
import org.matrix.android.sdk.api.session.room.timeline.TimelineSettings
|
||||||
import org.matrix.android.sdk.internal.database.model.TimelineEventEntity
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.util.Collections
|
import java.util.Collections
|
||||||
|
|
||||||
@ -52,25 +50,25 @@ internal class UIEchoManager(
|
|||||||
|
|
||||||
private val inMemoryReactions = Collections.synchronizedMap<String, MutableList<ReactionUiEchoData>>(HashMap())
|
private val inMemoryReactions = Collections.synchronizedMap<String, MutableList<ReactionUiEchoData>>(HashMap())
|
||||||
|
|
||||||
fun sentEventsUpdated(events: RealmResults<TimelineEventEntity>) {
|
fun onSentEventsInDatabase(eventIds: List<String>) {
|
||||||
// Remove in memory as soon as they are known by database
|
// Remove in memory as soon as they are known by database
|
||||||
events.forEach { te ->
|
eventIds.forEach { eventId ->
|
||||||
inMemorySendingEvents.removeAll { te.eventId == it.eventId }
|
inMemorySendingEvents.removeAll { eventId == it.eventId }
|
||||||
}
|
}
|
||||||
inMemorySendingStates.keys.removeAll { key ->
|
inMemorySendingStates.keys.removeAll { key ->
|
||||||
events.find { it.eventId == key } == null
|
eventIds.find { it == key } == null
|
||||||
}
|
}
|
||||||
|
|
||||||
inMemoryReactions.forEach { (_, uiEchoData) ->
|
inMemoryReactions.forEach { (_, uiEchoData) ->
|
||||||
uiEchoData.removeAll { data ->
|
uiEchoData.removeAll { data ->
|
||||||
// I remove the uiEcho, when the related event is not anymore in the sending list
|
// I remove the uiEcho, when the related event is not anymore in the sending list
|
||||||
// (means that it is synced)!
|
// (means that it is synced)!
|
||||||
events.find { it.eventId == data.localEchoId } == null
|
eventIds.find { it == data.localEchoId } == null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onLocalEchoUpdated(eventId: String, sendState: SendState): Boolean {
|
fun onSendStateUpdated(eventId: String, sendState: SendState): Boolean {
|
||||||
val existingState = inMemorySendingStates[eventId]
|
val existingState = inMemorySendingStates[eventId]
|
||||||
inMemorySendingStates[eventId] = sendState
|
inMemorySendingStates[eventId] = sendState
|
||||||
return existingState != sendState
|
return existingState != sendState
|
||||||
|
Loading…
x
Reference in New Issue
Block a user