1
0
mirror of https://github.com/vector-im/riotX-android synced 2025-10-06 00:02:48 +02:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Onuray Sahin
6f87632905 Fix last message of rooms in the room list. 2021-01-13 18:24:08 +03:00
Onuray Sahin
1c086a6c94 Changelog added. 2021-01-13 11:57:55 +03:00
Onuray Sahin
1507ad0500 Include sending state when sorting timeline events. 2021-01-12 20:00:40 +03:00
Onuray Sahin
cdc211e17d Set originServerTs of local echos as later than the last previewable event. 2021-01-11 21:36:22 +03:00
7 changed files with 29 additions and 19 deletions

View File

@@ -17,6 +17,7 @@ Bugfix 🐛:
- Tapping drawer having more than 1 room in notifications gives "malformed link" error (#2605)
- Sent image not displayed when opened immediately after sending (#409)
- Initial sync is not retried correctly when there is some network error. (#2632)
- Order of sent messages are not always respected (#729)
Translations 🗣:
-

View File

@@ -368,7 +368,7 @@ internal class VerificationTransportRoomMessage(
private fun createEventAndLocalEcho(localId: String = LocalEcho.createLocalEchoId(), type: String, roomId: String, content: Content): Event {
return Event(
roomId = roomId,
originServerTs = System.currentTimeMillis(),
originServerTs = localEchoEventFactory.dummyOriginServerTs(roomId),
senderId = userId,
eventId = localId,
type = type,

View File

@@ -60,14 +60,18 @@ internal fun TimelineEventEntity.Companion.latestEvent(realm: Realm,
val roomEntity = RoomEntity.where(realm, roomId).findFirst() ?: return null
val sendingTimelineEvents = roomEntity.sendingTimelineEvents.where().filterEvents(filters)
val liveEvents = ChunkEntity.findLastForwardChunkOfRoom(realm, roomId)?.timelineEvents?.where()?.filterEvents(filters)
val query = if (includesSending && sendingTimelineEvents.findAll().isNotEmpty()) {
sendingTimelineEvents
val latestLiveEvent = liveEvents?.sort(TimelineEventEntityFields.DISPLAY_INDEX, Sort.DESCENDING)?.findFirst()
return if (includesSending) {
sendingTimelineEvents.findAll().toMutableList().maxByOrNull { it.root?.originServerTs ?: 0 }?.let {
maxOf(latestLiveEvent, it, {a, b -> ((a?.root?.originServerTs ?: 0) - (b?.root?.originServerTs ?: 0)).toInt() })
} ?: run {
latestLiveEvent
}
} else {
liveEvents
latestLiveEvent
}
return query
?.sort(TimelineEventEntityFields.DISPLAY_INDEX, Sort.DESCENDING)
?.findFirst()
}
internal fun RealmQuery<TimelineEventEntity>.filterEvents(filters: TimelineEventFilters): RealmQuery<TimelineEventEntity> {

View File

@@ -138,7 +138,7 @@ internal class MxCallImpl(
private fun createEventAndLocalEcho(localId: String = LocalEcho.createLocalEchoId(), type: String, roomId: String, content: Content): Event {
return Event(
roomId = roomId,
originServerTs = System.currentTimeMillis(),
originServerTs = localEchoEventFactory.dummyOriginServerTs(roomId),
senderId = userId,
eventId = localId,
type = type,

View File

@@ -55,10 +55,12 @@ import org.matrix.android.sdk.api.session.room.model.relation.ReplyToContent
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
import org.matrix.android.sdk.api.session.room.timeline.getLastMessageContent
import org.matrix.android.sdk.api.session.room.timeline.isReply
import org.matrix.android.sdk.internal.database.RealmSessionProvider
import org.matrix.android.sdk.internal.di.UserId
import org.matrix.android.sdk.internal.session.content.ThumbnailExtractor
import org.matrix.android.sdk.internal.session.permalinks.PermalinkFactory
import org.matrix.android.sdk.internal.session.room.send.pills.TextPillsUtils
import org.matrix.android.sdk.internal.session.room.summary.RoomSummaryEventsHelper
import org.matrix.android.sdk.internal.util.StringProvider
import javax.inject.Inject
@@ -78,7 +80,8 @@ internal class LocalEchoEventFactory @Inject constructor(
private val markdownParser: MarkdownParser,
private val textPillsUtils: TextPillsUtils,
private val localEchoRepository: LocalEchoRepository,
private val permalinkFactory: PermalinkFactory
private val permalinkFactory: PermalinkFactory,
private val realmSessionProvider: RealmSessionProvider
) {
fun createTextEvent(roomId: String, msgType: String, text: CharSequence, autoMarkdown: Boolean): Event {
if (msgType == MessageType.MSGTYPE_TEXT || msgType == MessageType.MSGTYPE_EMOTE) {
@@ -203,7 +206,7 @@ internal class LocalEchoEventFactory @Inject constructor(
ContentAttachmentData.Type.IMAGE -> createImageEvent(roomId, attachment)
ContentAttachmentData.Type.VIDEO -> createVideoEvent(roomId, attachment)
ContentAttachmentData.Type.AUDIO -> createAudioEvent(roomId, attachment)
ContentAttachmentData.Type.FILE -> createFileEvent(roomId, attachment)
ContentAttachmentData.Type.FILE -> createFileEvent(roomId, attachment)
}
}
@@ -218,7 +221,7 @@ internal class LocalEchoEventFactory @Inject constructor(
val localId = LocalEcho.createLocalEchoId()
return Event(
roomId = roomId,
originServerTs = dummyOriginServerTs(),
originServerTs = dummyOriginServerTs(roomId),
senderId = userId,
eventId = localId,
type = EventType.REACTION,
@@ -325,7 +328,7 @@ internal class LocalEchoEventFactory @Inject constructor(
val localId = LocalEcho.createLocalEchoId()
return Event(
roomId = roomId,
originServerTs = dummyOriginServerTs(),
originServerTs = dummyOriginServerTs(roomId),
senderId = userId,
eventId = localId,
type = type,
@@ -338,7 +341,7 @@ internal class LocalEchoEventFactory @Inject constructor(
val localId = LocalEcho.createLocalEchoId()
return Event(
roomId = roomId,
originServerTs = dummyOriginServerTs(),
originServerTs = dummyOriginServerTs(roomId),
senderId = userId,
eventId = localId,
type = EventType.MESSAGE,
@@ -353,8 +356,10 @@ internal class LocalEchoEventFactory @Inject constructor(
)
}
private fun dummyOriginServerTs(): Long {
return System.currentTimeMillis()
fun dummyOriginServerTs(roomId: String): Long {
return realmSessionProvider.withRealm { realm ->
(RoomSummaryEventsHelper.getLatestPreviewableEvent(realm, roomId, false)?.root?.originServerTs ?: System.currentTimeMillis()) + 1
}
}
fun createReplyTextEvent(roomId: String,
@@ -459,7 +464,7 @@ internal class LocalEchoEventFactory @Inject constructor(
val localId = LocalEcho.createLocalEchoId()
return Event(
roomId = roomId,
originServerTs = dummyOriginServerTs(),
originServerTs = dummyOriginServerTs(roomId),
senderId = userId,
eventId = localId,
type = EventType.REDACTION,

View File

@@ -33,11 +33,11 @@ internal object RoomSummaryEventsHelper {
filterEdits = true
)
fun getLatestPreviewableEvent(realm: Realm, roomId: String): TimelineEventEntity? {
fun getLatestPreviewableEvent(realm: Realm, roomId: String, includeSending: Boolean = true): TimelineEventEntity? {
return TimelineEventEntity.latestEvent(
realm = realm,
roomId = roomId,
includesSending = true,
includesSending = includeSending,
filters = previewFilters
)
}

View File

@@ -408,7 +408,7 @@ internal class DefaultTimeline(
}
private fun createSnapshot(): List<TimelineEvent> {
return buildSendingEvents() + builtEvents.toList()
return (buildSendingEvents() + builtEvents.toList()).sortedByDescending { it.root.originServerTs }
}
private fun buildSendingEvents(): List<TimelineEvent> {