mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-29 14:38:45 +03:00
Avoid missing timestamps due to missing previewable event
Just use a non-previewable event instead. Improves sorting of the room list: don't drop rooms to the bottom because of too much un-previewable activity. Change-Id: Ib1ad8050caae85a3e7c8a686c2fa63a2924db890
This commit is contained in:
parent
d74b8b76e8
commit
c214e5daf1
4 changed files with 22 additions and 5 deletions
|
@ -53,6 +53,7 @@ data class RoomSummary(
|
|||
val hasUnreadMessages: Boolean = false,
|
||||
val hasUnreadContentMessages: Boolean = false,
|
||||
val hasUnreadOriginalContentMessages: Boolean = false,
|
||||
val lastActivityTime: Long? = null,
|
||||
val unreadCount: Int? = null,
|
||||
val markedUnread: Boolean = false,
|
||||
val aggregatedUnreadCount: Int = 0,
|
||||
|
|
|
@ -73,6 +73,7 @@ internal class RoomSummaryMapper @Inject constructor(private val timelineEventMa
|
|||
hasUnreadMessages = roomSummaryEntity.hasUnreadMessages,
|
||||
hasUnreadContentMessages = roomSummaryEntity.hasUnreadContentMessages,
|
||||
hasUnreadOriginalContentMessages = roomSummaryEntity.hasUnreadOriginalContentMessages,
|
||||
lastActivityTime = roomSummaryEntity.lastActivityTime,
|
||||
markedUnread = roomSummaryEntity.markedUnread,
|
||||
tags = tags,
|
||||
typingUsers = typingUsers,
|
||||
|
|
|
@ -56,6 +56,7 @@ import org.matrix.android.sdk.internal.database.query.findAllInRoomWithSendState
|
|||
import org.matrix.android.sdk.internal.database.query.getOrCreate
|
||||
import org.matrix.android.sdk.internal.database.query.getOrNull
|
||||
import org.matrix.android.sdk.internal.database.query.isEventRead
|
||||
import org.matrix.android.sdk.internal.database.query.latestEvent
|
||||
import org.matrix.android.sdk.internal.database.query.where
|
||||
import org.matrix.android.sdk.internal.di.UserId
|
||||
import org.matrix.android.sdk.internal.extensions.clearWith
|
||||
|
@ -153,12 +154,24 @@ internal class RoomSummaryUpdater @Inject constructor(
|
|||
val lastActivityFromEvent = scLatestPreviewableEvent?.root?.originServerTs
|
||||
if (lastActivityFromEvent != null) {
|
||||
roomSummaryEntity.lastActivityTime = lastActivityFromEvent
|
||||
} else if (latestPreviewableEvent != scLatestPreviewableEvent) {
|
||||
// Try using a less aggressive previewable filter for last activity, so we avoid null timestamps, which would just drop the room to the bottom
|
||||
roomSummaryEntity.lastActivityTime = latestPreviewableEvent?.root?.originServerTs
|
||||
}
|
||||
// If we still did not find a timestamp for the last activity:
|
||||
// Any (non-previewable) event is still better for sorting than just dropping the room to the bottom in the list
|
||||
if (roomSummaryEntity.lastActivityTime == null) {
|
||||
roomSummaryEntity.lastActivityTime = TimelineEventEntity.latestEvent(
|
||||
realm = realm,
|
||||
roomId = roomId,
|
||||
includesSending = true
|
||||
)?.root?.originServerTs
|
||||
}
|
||||
attemptToDecryptLatestPreviewables(
|
||||
roomSummaryEntity.latestPreviewableEvent,
|
||||
roomSummaryEntity.latestPreviewableContentEvent,
|
||||
roomSummaryEntity.latestPreviewableOriginalContentEvent
|
||||
)
|
||||
}
|
||||
|
||||
val roomSummaryUnreadCount = roomSummaryEntity.unreadCount
|
||||
if (roomSummaryUnreadCount != null /* && preferences.prioritizeUnreadCountsOverRoomPreviewsForUnreadCalculation() */) {
|
||||
|
|
|
@ -117,6 +117,8 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor
|
|||
if (latestEvent != null) {
|
||||
latestFormattedEvent = displayableEventFormatter.format(latestEvent, roomSummary.isDirect, roomSummary.isDirect.not())
|
||||
latestEventTime = dateFormatter.format(latestEvent.root.originServerTs, DateFormatKind.ROOM_LIST)
|
||||
} else if (roomSummary.lastActivityTime != null) {
|
||||
latestEventTime = dateFormatter.format(roomSummary.lastActivityTime, DateFormatKind.ROOM_LIST)
|
||||
}
|
||||
val typingMessage = typingHelper.getTypingMessage(roomSummary.typingUsers)
|
||||
return RoomSummaryItem_()
|
||||
|
|
Loading…
Reference in a new issue