PowerLevel: use new api exposed from rust which doesn't need to load members.

This commit is contained in:
ganfra 2023-07-18 15:10:44 +02:00
parent 1a9f0732e1
commit e00462900e
10 changed files with 74 additions and 37 deletions

View file

@ -21,11 +21,12 @@ import androidx.compose.runtime.State
import androidx.compose.runtime.produceState
import io.element.android.libraries.matrix.api.room.MatrixRoom
import io.element.android.libraries.matrix.api.room.MessageEventType
import io.element.android.libraries.matrix.api.room.powerlevels.canSendMessage
@Composable
fun MatrixRoom.canSendEventAsState(type: MessageEventType, updateKey: Long): State<Boolean> {
fun MatrixRoom.canSendMessageAsState(type: MessageEventType, updateKey: Long): State<Boolean> {
return produceState(initialValue = true, key1 = updateKey) {
value = canSendEvent(type).getOrElse { true }
value = canSendMessage(type).getOrElse { true }
}
}