Room list : adjust some params

This commit is contained in:
ganfra 2019-01-29 18:31:11 +01:00
parent 6df8809ee0
commit 0e491af8ab
3 changed files with 8 additions and 3 deletions

View File

@ -11,7 +11,7 @@
android:gravity="center_vertical"
android:paddingLeft="16dp"
android:paddingTop="8dp"
android:paddingRight="16dp"
android:paddingRight="8dp"
android:paddingBottom="8dp"
tools:background="@color/pale_grey">

View File

@ -51,10 +51,15 @@ internal fun EventEntity.Companion.where(realm: Realm,
internal fun EventEntity.Companion.latestEvent(realm: Realm,
roomId: String,
includedTypes: List<String> = emptyList(),
excludedTypes: List<String> = emptyList()): EventEntity? {
val query = ChunkEntity.findLastLiveChunkFromRoom(realm, roomId)?.events?.where()
if (includedTypes.isNotEmpty()) {
query?.`in`(EventEntityFields.TYPE, includedTypes.toTypedArray())
} else if (excludedTypes.isNotEmpty()) {
query?.not()?.`in`(EventEntityFields.TYPE, excludedTypes.toTypedArray())
}
return query
?.not()?.`in`(EventEntityFields.TYPE, excludedTypes.toTypedArray())
?.sort(EventEntityFields.DISPLAY_INDEX)
?.findFirst()
}

View File

@ -58,7 +58,7 @@ internal class RoomSummaryUpdater(monarchy: Monarchy,
val roomSummary = RoomSummaryEntity.where(realm, roomId).findFirst()
?: realm.createObject(roomId)
val lastEvent = EventEntity.latestEvent(realm, roomId)
val lastEvent = EventEntity.latestEvent(realm, roomId, includedTypes = listOf(EventType.MESSAGE))
val lastTopicEvent = EventEntity.where(realm, roomId, EventType.STATE_ROOM_TOPIC).last()?.asDomain()
val otherRoomMembers = RoomMembers(realm, roomId).getLoaded().filterKeys { it != credentials.userId }