Allow user with enough power level to redact other's messages (#969)

This commit is contained in:
Benoit Marty 2023-07-27 17:53:28 +02:00
parent cd5b9ea3f9
commit 82e35cda0d
13 changed files with 112 additions and 18 deletions

View file

@ -21,6 +21,7 @@ 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.canRedact
import io.element.android.libraries.matrix.api.room.powerlevels.canSendMessage
@Composable
@ -30,3 +31,10 @@ fun MatrixRoom.canSendMessageAsState(type: MessageEventType, updateKey: Long): S
}
}
@Composable
fun MatrixRoom.canRedactAsState(updateKey: Long): State<Boolean> {
return produceState(initialValue = false, key1 = updateKey) {
value = canRedact().getOrElse { false }
}
}