Properly sort rooms according to events previewed in summary
Change-Id: Id17385a4d17869b0356aa7242407581e2193845e
This commit is contained in:
parent
3ee98f3c94
commit
2605c6ac9b
|
@ -100,13 +100,13 @@ data class RoomSummary constructor(
|
||||||
fun scLatestPreviewableEvent(preferenceProvider: RoomSummaryPreferenceProvider?): TimelineEvent? {
|
fun scLatestPreviewableEvent(preferenceProvider: RoomSummaryPreferenceProvider?): TimelineEvent? {
|
||||||
if (preferenceProvider == null) {
|
if (preferenceProvider == null) {
|
||||||
// Fallback to default
|
// Fallback to default
|
||||||
return latestPreviewableEvent
|
return latestPreviewableOriginalContentEvent
|
||||||
}
|
}
|
||||||
return when(preferenceProvider.getUnreadKind(isDirect)) {
|
return when(preferenceProvider.getUnreadKind(isDirect)) {
|
||||||
UNREAD_KIND_ORIGINAL_CONTENT -> latestPreviewableOriginalContentEvent
|
UNREAD_KIND_ORIGINAL_CONTENT -> latestPreviewableOriginalContentEvent
|
||||||
UNREAD_KIND_CONTENT -> latestPreviewableContentEvent
|
UNREAD_KIND_CONTENT -> latestPreviewableContentEvent
|
||||||
// UNREAD_KIND_DEFAULT
|
// UNREAD_KIND_DEFAULT
|
||||||
else -> latestPreviewableEvent
|
else -> latestPreviewableOriginalContentEvent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -207,7 +207,7 @@ class RealmSessionStoreMigration @Inject constructor() : RealmMigration {
|
||||||
obj.setBoolean(RoomSummaryEntityFields.IS_LOW_PRIORITY, isLowPriority)
|
obj.setBoolean(RoomSummaryEntityFields.IS_LOW_PRIORITY, isLowPriority)
|
||||||
|
|
||||||
// XXX migrate last message origin server ts
|
// XXX migrate last message origin server ts
|
||||||
obj.getObject(RoomSummaryEntityFields.LATEST_PREVIEWABLE_EVENT.`$`)
|
obj.getObject(RoomSummaryEntityFields.LATEST_PREVIEWABLE_ORIGINAL_CONTENT_EVENT.`$`)
|
||||||
?.getObject(TimelineEventEntityFields.ROOT.`$`)
|
?.getObject(TimelineEventEntityFields.ROOT.`$`)
|
||||||
?.getLong(EventEntityFields.ORIGIN_SERVER_TS)?.let {
|
?.getLong(EventEntityFields.ORIGIN_SERVER_TS)?.let {
|
||||||
obj.setLong(RoomSummaryEntityFields.LAST_ACTIVITY_TIME, it)
|
obj.setLong(RoomSummaryEntityFields.LAST_ACTIVITY_TIME, it)
|
||||||
|
|
|
@ -100,7 +100,7 @@ internal class RoomSummaryUpdater @Inject constructor(
|
||||||
val latestPreviewableContentEvent = RoomSummaryEventsHelper.getLatestPreviewableEvent(realm, roomId)
|
val latestPreviewableContentEvent = RoomSummaryEventsHelper.getLatestPreviewableEvent(realm, roomId)
|
||||||
val latestPreviewableOriginalContentEvent = RoomSummaryEventsHelper.getLatestPreviewableEventScOriginalContent(realm, roomId)
|
val latestPreviewableOriginalContentEvent = RoomSummaryEventsHelper.getLatestPreviewableEventScOriginalContent(realm, roomId)
|
||||||
|
|
||||||
val lastActivityFromEvent = latestPreviewableEvent?.root?.originServerTs
|
val lastActivityFromEvent = latestPreviewableOriginalContentEvent?.root?.originServerTs
|
||||||
if (lastActivityFromEvent != null) {
|
if (lastActivityFromEvent != null) {
|
||||||
roomSummaryEntity.lastActivityTime = lastActivityFromEvent
|
roomSummaryEntity.lastActivityTime = lastActivityFromEvent
|
||||||
}
|
}
|
||||||
|
@ -140,9 +140,9 @@ internal class RoomSummaryUpdater @Inject constructor(
|
||||||
}
|
}
|
||||||
roomSummaryEntity.updateHasFailedSending()
|
roomSummaryEntity.updateHasFailedSending()
|
||||||
|
|
||||||
val root = latestPreviewableEvent?.root
|
val root = latestPreviewableOriginalContentEvent?.root
|
||||||
if (root?.type == EventType.ENCRYPTED && root.decryptionResultJson == null) {
|
if (root?.type == EventType.ENCRYPTED && root.decryptionResultJson == null) {
|
||||||
Timber.v("Should decrypt ${latestPreviewableEvent.eventId}")
|
Timber.v("Should decrypt ${latestPreviewableOriginalContentEvent.eventId}")
|
||||||
// mmm i want to decrypt now or is it ok to do it async?
|
// mmm i want to decrypt now or is it ok to do it async?
|
||||||
tryOrNull {
|
tryOrNull {
|
||||||
eventDecryptor.decryptEvent(root.asDomain(), "")
|
eventDecryptor.decryptEvent(root.asDomain(), "")
|
||||||
|
@ -174,5 +174,7 @@ internal class RoomSummaryUpdater @Inject constructor(
|
||||||
val roomSummaryEntity = RoomSummaryEntity.getOrCreate(realm, roomId)
|
val roomSummaryEntity = RoomSummaryEntity.getOrCreate(realm, roomId)
|
||||||
roomSummaryEntity.updateHasFailedSending()
|
roomSummaryEntity.updateHasFailedSending()
|
||||||
roomSummaryEntity.latestPreviewableEvent = RoomSummaryEventsHelper.getLatestPreviewableEvent(realm, roomId)
|
roomSummaryEntity.latestPreviewableEvent = RoomSummaryEventsHelper.getLatestPreviewableEvent(realm, roomId)
|
||||||
|
roomSummaryEntity.latestPreviewableContentEvent = RoomSummaryEventsHelper.getLatestPreviewableEvent(realm, roomId)
|
||||||
|
roomSummaryEntity.latestPreviewableOriginalContentEvent = RoomSummaryEventsHelper.getLatestPreviewableEventScOriginalContent(realm, roomId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,6 +175,8 @@ internal class TokenChunkEventPersistor @Inject constructor(@SessionDatabase pri
|
||||||
currentLastForwardChunk?.deleteOnCascade(deleteStateEvents = false, canDeleteRoot = false)
|
currentLastForwardChunk?.deleteOnCascade(deleteStateEvents = false, canDeleteRoot = false)
|
||||||
RoomSummaryEntity.where(realm, roomId).findFirst()?.apply {
|
RoomSummaryEntity.where(realm, roomId).findFirst()?.apply {
|
||||||
latestPreviewableEvent = RoomSummaryEventsHelper.getLatestPreviewableEvent(realm, roomId)
|
latestPreviewableEvent = RoomSummaryEventsHelper.getLatestPreviewableEvent(realm, roomId)
|
||||||
|
latestPreviewableContentEvent = RoomSummaryEventsHelper.getLatestPreviewableEvent(realm, roomId)
|
||||||
|
latestPreviewableOriginalContentEvent = RoomSummaryEventsHelper.getLatestPreviewableEventScOriginalContent(realm, roomId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -238,10 +240,10 @@ internal class TokenChunkEventPersistor @Inject constructor(@SessionDatabase pri
|
||||||
it.deleteOnCascade(deleteStateEvents = false, canDeleteRoot = false)
|
it.deleteOnCascade(deleteStateEvents = false, canDeleteRoot = false)
|
||||||
}
|
}
|
||||||
val roomSummaryEntity = RoomSummaryEntity.getOrCreate(realm, roomId)
|
val roomSummaryEntity = RoomSummaryEntity.getOrCreate(realm, roomId)
|
||||||
val shouldUpdateSummary = roomSummaryEntity.latestPreviewableEvent == null
|
val shouldUpdateSummary = roomSummaryEntity.latestPreviewableOriginalContentEvent == null
|
||||||
|| (chunksToDelete.isNotEmpty() && currentChunk.isLastForward && direction == PaginationDirection.FORWARDS)
|
|| (chunksToDelete.isNotEmpty() && currentChunk.isLastForward && direction == PaginationDirection.FORWARDS)
|
||||||
if (shouldUpdateSummary) {
|
if (shouldUpdateSummary) {
|
||||||
roomSummaryEntity.latestPreviewableEvent = RoomSummaryEventsHelper.getLatestPreviewableEvent(realm, roomId)
|
roomSummaryEntity.latestPreviewableOriginalContentEvent = RoomSummaryEventsHelper.getLatestPreviewableEventScOriginalContent(realm, roomId)
|
||||||
}
|
}
|
||||||
if (currentChunk.isValid) {
|
if (currentChunk.isValid) {
|
||||||
RoomEntity.where(realm, roomId).findFirst()?.addIfNecessary(currentChunk)
|
RoomEntity.where(realm, roomId).findFirst()?.addIfNecessary(currentChunk)
|
||||||
|
|
Loading…
Reference in New Issue