From 0e491af8abc8813c27fad05c1ba03e32d40646e1 Mon Sep 17 00:00:00 2001 From: ganfra Date: Tue, 29 Jan 2019 18:31:11 +0100 Subject: [PATCH] Room list : adjust some params --- app/src/main/res/layout/item_room_category.xml | 2 +- .../android/internal/database/query/EventEntityQueries.kt | 7 ++++++- .../android/internal/session/room/RoomSummaryUpdater.kt | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/layout/item_room_category.xml b/app/src/main/res/layout/item_room_category.xml index 29c12dfa..f84f9c42 100644 --- a/app/src/main/res/layout/item_room_category.xml +++ b/app/src/main/res/layout/item_room_category.xml @@ -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"> diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/query/EventEntityQueries.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/query/EventEntityQueries.kt index 80e194e3..015a47ac 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/query/EventEntityQueries.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/database/query/EventEntityQueries.kt @@ -51,10 +51,15 @@ internal fun EventEntity.Companion.where(realm: Realm, internal fun EventEntity.Companion.latestEvent(realm: Realm, roomId: String, + includedTypes: List = emptyList(), excludedTypes: List = 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() } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomSummaryUpdater.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomSummaryUpdater.kt index 3e5fe1b1..4d690832 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomSummaryUpdater.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/RoomSummaryUpdater.kt @@ -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 }