diff --git a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt index 8a94fa30f7..48ff66720f 100644 --- a/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt +++ b/matrix-sdk-android-rx/src/main/java/im/vector/matrix/rx/RxRoom.kt @@ -35,10 +35,12 @@ class RxRoom(private val room: Room) { fun liveRoomMembers(memberships: List): Observable> { return room.getRoomMembersLive(memberships).asObservable() + .startWith(room.getRoomMembers(memberships)) } fun liveAnnotationSummary(eventId: String): Observable> { - return room.getEventSummaryLive(eventId).asObservable() + return room.getEventAnnotationsSummaryLive(eventId).asObservable() + .startWith(room.getEventAnnotationsSummary(eventId).toOptional()) } fun liveTimelineEvent(eventId: String): Observable> { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/members/MembershipService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/members/MembershipService.kt index 12f0378af7..281697816c 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/members/MembershipService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/members/MembershipService.kt @@ -41,6 +41,14 @@ interface MembershipService { */ fun getRoomMember(userId: String): RoomMember? + + /** + * Return all the roomMembers of the room filtered by memberships + * @param memberships list of accepted memberships + * @return a roomMember list. + */ + fun getRoomMembers(memberships: List): List + /** * Return all the roomMembers of the room filtered by memberships * @param memberships list of accepted memberships diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/relation/RelationService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/relation/RelationService.kt index 7d8f2f0bc1..d13d7db773 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/relation/RelationService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/session/room/model/relation/RelationService.kt @@ -108,5 +108,17 @@ interface RelationService { replyText: CharSequence, autoMarkdown: Boolean = false): Cancelable? - fun getEventSummaryLive(eventId: String): LiveData> + /** + * Get the current EventAnnotationsSummary + * @param eventId the eventId to look for EventAnnotationsSummary + * @return the EventAnnotationsSummary found + */ + fun getEventAnnotationsSummary(eventId: String): EventAnnotationsSummary? + + /** + * Get the a LiveData EventAnnotationsSummary + * @param eventId the eventId to look for EventAnnotationsSummary + * @return the LiveData of EventAnnotationsSummary + */ + fun getEventAnnotationsSummaryLive(eventId: String): LiveData> } diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/membership/DefaultMembershipService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/membership/DefaultMembershipService.kt index 2b89f86d3e..789b783e3f 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/membership/DefaultMembershipService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/membership/DefaultMembershipService.kt @@ -64,6 +64,17 @@ internal class DefaultMembershipService @AssistedInject constructor(@Assisted pr return roomMemberEntity?.asDomain() } + override fun getRoomMembers(memberships: List): List { + return monarchy.fetchAllMappedSync( + { + RoomMembers(it, roomId).queryRoomMembersEvent() + }, + { + it.asDomain() + } + ) + } + override fun getRoomMembersLive(memberships: List): LiveData> { return monarchy.findAllMappedWithChanges( { diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/relation/DefaultRelationService.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/relation/DefaultRelationService.kt index 8731045e14..180776ba8d 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/relation/DefaultRelationService.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/internal/session/room/relation/DefaultRelationService.kt @@ -215,7 +215,16 @@ internal class DefaultRelationService @AssistedInject constructor(@Assisted priv return TimelineSendEventWorkCommon.createWork(sendWorkData, startChain) } - override fun getEventSummaryLive(eventId: String): LiveData> { + override fun getEventAnnotationsSummary(eventId: String): EventAnnotationsSummary? { + return monarchy.fetchCopyMap( + { EventAnnotationsSummaryEntity.where(it, eventId).findFirst() }, + { entity, _ -> + entity.asDomain() + } + ) + } + + override fun getEventAnnotationsSummaryLive(eventId: String): LiveData> { val liveData = monarchy.findAllMappedWithChanges( { EventAnnotationsSummaryEntity.where(it, eventId) }, { it.asDomain() }