mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-27 11:09:18 +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 hasUnreadMessages: Boolean = false,
|
||||||
val hasUnreadContentMessages: Boolean = false,
|
val hasUnreadContentMessages: Boolean = false,
|
||||||
val hasUnreadOriginalContentMessages: Boolean = false,
|
val hasUnreadOriginalContentMessages: Boolean = false,
|
||||||
|
val lastActivityTime: Long? = null,
|
||||||
val unreadCount: Int? = null,
|
val unreadCount: Int? = null,
|
||||||
val markedUnread: Boolean = false,
|
val markedUnread: Boolean = false,
|
||||||
val aggregatedUnreadCount: Int = 0,
|
val aggregatedUnreadCount: Int = 0,
|
||||||
|
|
|
@ -73,6 +73,7 @@ internal class RoomSummaryMapper @Inject constructor(private val timelineEventMa
|
||||||
hasUnreadMessages = roomSummaryEntity.hasUnreadMessages,
|
hasUnreadMessages = roomSummaryEntity.hasUnreadMessages,
|
||||||
hasUnreadContentMessages = roomSummaryEntity.hasUnreadContentMessages,
|
hasUnreadContentMessages = roomSummaryEntity.hasUnreadContentMessages,
|
||||||
hasUnreadOriginalContentMessages = roomSummaryEntity.hasUnreadOriginalContentMessages,
|
hasUnreadOriginalContentMessages = roomSummaryEntity.hasUnreadOriginalContentMessages,
|
||||||
|
lastActivityTime = roomSummaryEntity.lastActivityTime,
|
||||||
markedUnread = roomSummaryEntity.markedUnread,
|
markedUnread = roomSummaryEntity.markedUnread,
|
||||||
tags = tags,
|
tags = tags,
|
||||||
typingUsers = typingUsers,
|
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.getOrCreate
|
||||||
import org.matrix.android.sdk.internal.database.query.getOrNull
|
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.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.database.query.where
|
||||||
import org.matrix.android.sdk.internal.di.UserId
|
import org.matrix.android.sdk.internal.di.UserId
|
||||||
import org.matrix.android.sdk.internal.extensions.clearWith
|
import org.matrix.android.sdk.internal.extensions.clearWith
|
||||||
|
@ -153,12 +154,24 @@ internal class RoomSummaryUpdater @Inject constructor(
|
||||||
val lastActivityFromEvent = scLatestPreviewableEvent?.root?.originServerTs
|
val lastActivityFromEvent = scLatestPreviewableEvent?.root?.originServerTs
|
||||||
if (lastActivityFromEvent != null) {
|
if (lastActivityFromEvent != null) {
|
||||||
roomSummaryEntity.lastActivityTime = lastActivityFromEvent
|
roomSummaryEntity.lastActivityTime = lastActivityFromEvent
|
||||||
attemptToDecryptLatestPreviewables(
|
} else if (latestPreviewableEvent != scLatestPreviewableEvent) {
|
||||||
roomSummaryEntity.latestPreviewableEvent,
|
// 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.latestPreviewableContentEvent,
|
roomSummaryEntity.lastActivityTime = latestPreviewableEvent?.root?.originServerTs
|
||||||
roomSummaryEntity.latestPreviewableOriginalContentEvent
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
// 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
|
val roomSummaryUnreadCount = roomSummaryEntity.unreadCount
|
||||||
if (roomSummaryUnreadCount != null /* && preferences.prioritizeUnreadCountsOverRoomPreviewsForUnreadCalculation() */) {
|
if (roomSummaryUnreadCount != null /* && preferences.prioritizeUnreadCountsOverRoomPreviewsForUnreadCalculation() */) {
|
||||||
|
|
|
@ -117,6 +117,8 @@ class RoomSummaryItemFactory @Inject constructor(private val displayableEventFor
|
||||||
if (latestEvent != null) {
|
if (latestEvent != null) {
|
||||||
latestFormattedEvent = displayableEventFormatter.format(latestEvent, roomSummary.isDirect, roomSummary.isDirect.not())
|
latestFormattedEvent = displayableEventFormatter.format(latestEvent, roomSummary.isDirect, roomSummary.isDirect.not())
|
||||||
latestEventTime = dateFormatter.format(latestEvent.root.originServerTs, DateFormatKind.ROOM_LIST)
|
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)
|
val typingMessage = typingHelper.getTypingMessage(roomSummary.typingUsers)
|
||||||
return RoomSummaryItem_()
|
return RoomSummaryItem_()
|
||||||
|
|
Loading…
Add table
Reference in a new issue