Remove unnecessary Room.updateMembers() calls. (#2564)
* Remove unnecessary `updateMembers` calls. Some of them can be directly removed since we have a way to automatically get member info updates based on membership changes. Others can be replaced by a simpler `getUpdatedMember` method. This might still need a full member sync, but it's quite unlikely.
This commit is contained in:
parent
fde154a284
commit
883d834284
8 changed files with 26 additions and 37 deletions
|
|
@ -86,6 +86,11 @@ interface MatrixRoom : Closeable {
|
|||
*/
|
||||
suspend fun updateMembers()
|
||||
|
||||
/**
|
||||
* Will return an updated member or an error.
|
||||
*/
|
||||
suspend fun getUpdatedMember(userId: UserId): Result<RoomMember>
|
||||
|
||||
suspend fun updateRoomNotificationSettings(): Result<Unit>
|
||||
|
||||
val syncUpdateFlow: StateFlow<Long>
|
||||
|
|
|
|||
|
|
@ -230,6 +230,12 @@ class RustMatrixRoom(
|
|||
roomMemberListFetcher.fetchRoomMembers(source = source)
|
||||
}
|
||||
|
||||
override suspend fun getUpdatedMember(userId: UserId): Result<RoomMember> = withContext(roomDispatcher) {
|
||||
runCatching {
|
||||
RoomMemberMapper.map(innerRoom.member(userId.value))
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun userDisplayName(userId: UserId): Result<String?> = withContext(roomDispatcher) {
|
||||
runCatching {
|
||||
innerRoom.memberDisplayName(userId.value)
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class FakeMatrixRoom(
|
|||
private var userDisplayNameResult = Result.success<String?>(null)
|
||||
private var userAvatarUrlResult = Result.success<String?>(null)
|
||||
private var userRoleResult = Result.success(RoomMember.Role.USER)
|
||||
private var updateMembersResult: Result<Unit> = Result.success(Unit)
|
||||
private var getRoomMemberResult = Result.failure<RoomMember>(IllegalStateException("Member not found"))
|
||||
private var joinRoomResult = Result.success(Unit)
|
||||
private var inviteUserResult = Result.success(Unit)
|
||||
private var canInviteResult = Result.success(true)
|
||||
|
|
@ -195,6 +195,10 @@ class FakeMatrixRoom(
|
|||
|
||||
override suspend fun updateMembers() = Unit
|
||||
|
||||
override suspend fun getUpdatedMember(userId: UserId): Result<RoomMember> {
|
||||
return getRoomMemberResult
|
||||
}
|
||||
|
||||
override suspend fun updateRoomNotificationSettings(): Result<Unit> = simulateLongTask {
|
||||
val notificationSettings = notificationSettingsService.getRoomNotificationSettings(roomId, isEncrypted, isOneToOne).getOrThrow()
|
||||
roomNotificationSettingsStateFlow.value = MatrixRoomNotificationSettingsState.Ready(notificationSettings)
|
||||
|
|
@ -532,8 +536,8 @@ class FakeMatrixRoom(
|
|||
membersStateFlow.value = state
|
||||
}
|
||||
|
||||
fun givenUpdateMembersResult(result: Result<Unit>) {
|
||||
updateMembersResult = result
|
||||
fun givenGetRoomMemberResult(result: Result<RoomMember>) {
|
||||
getRoomMemberResult = result
|
||||
}
|
||||
|
||||
fun givenUserDisplayNameResult(displayName: Result<String?>) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue