Add/Fix local echo to threads timeline

This commit is contained in:
ariskotsomitopoulos 2021-12-09 16:33:11 +02:00
parent c40a686cff
commit b1d4031a76
2 changed files with 24 additions and 14 deletions

View File

@ -168,24 +168,30 @@ internal class DefaultRelationService @AssistedInject constructor(
msgType: String,
autoMarkdown: Boolean,
formattedText: String?,
eventReplied: TimelineEvent?): Cancelable {
val event = eventReplied?.let {
eventReplied: TimelineEvent?): Cancelable? {
val event = if (eventReplied != null) {
eventFactory.createReplyTextEvent(
roomId = roomId,
eventReplied = eventReplied,
replyText = replyInThreadText,
autoMarkdown = autoMarkdown,
rootThreadEventId = rootThreadEventId)
} ?: eventFactory.createThreadTextEvent(
?.also {
saveLocalEcho(it)
} ?: return null
} else {
eventFactory.createThreadTextEvent(
rootThreadEventId = rootThreadEventId,
roomId = roomId,
text = replyInThreadText.toString(),
msgType = msgType,
autoMarkdown = autoMarkdown,
formattedText = formattedText)
// .also {
// saveLocalEcho(it)
// }
.also {
saveLocalEcho(it)
}
}
return eventSenderProcessor.postEvent(event, cryptoSessionInfoProvider.isRoomEncrypted(roomId))
}

View File

@ -448,7 +448,11 @@ internal class DefaultTimeline(
*/
private fun handleUpdates(results: RealmResults<TimelineEventEntity>, changeSet: OrderedCollectionChangeSet) {
// If changeSet has deletion we are having a gap, so we clear everything
if (changeSet.deletionRanges.isNotEmpty()) {
// I observed there is a problem with this implementation in the threads timeline upon receiving
// a local echo, after adding && !isFromThreadTimeline below fixed the issue.
// Maybe there is a deeper problem here even on the main timeline
if (changeSet.deletionRanges.isNotEmpty() && !isFromThreadTimeline) {
clearAllValues()
}
var postSnapshot = false