mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
Make BaseRoom.getDirectRoomMember change when roomInfo.isDm changes (#6989)
With `derivedStateOf` this wasn't working as expected for some reason, resulting in the dm member being null and displaying the wrong `RoomType` in the room details screen
This commit is contained in:
committed by
GitHub
parent
9fd5277a48
commit
786c53ac06
+3
-4
@@ -13,6 +13,7 @@ import androidx.compose.runtime.State
|
|||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.derivedStateOf
|
import androidx.compose.runtime.derivedStateOf
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import io.element.android.libraries.matrix.api.core.UserId
|
import io.element.android.libraries.matrix.api.core.UserId
|
||||||
import io.element.android.libraries.matrix.api.room.BaseRoom
|
import io.element.android.libraries.matrix.api.room.BaseRoom
|
||||||
@@ -42,10 +43,8 @@ fun getRoomMemberAsState(roomMembersState: RoomMembersState, userId: UserId): St
|
|||||||
@Composable
|
@Composable
|
||||||
fun BaseRoom.getDirectRoomMember(roomMembersState: RoomMembersState): State<RoomMember?> {
|
fun BaseRoom.getDirectRoomMember(roomMembersState: RoomMembersState): State<RoomMember?> {
|
||||||
val roomInfo by roomInfoFlow.collectAsState()
|
val roomInfo by roomInfoFlow.collectAsState()
|
||||||
return remember {
|
return remember(roomInfo.isDm) {
|
||||||
derivedStateOf {
|
mutableStateOf(roomMembersState.getDirectRoomMember(roomInfo, sessionId))
|
||||||
roomMembersState.getDirectRoomMember(roomInfo, sessionId)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user