@@ -14,88 +14,9 @@ import androidx.compose.runtime.collectAsState
1414import androidx.compose.runtime.getValue
1515import androidx.compose.runtime.produceState
1616import io.element.android.libraries.matrix.api.room.BaseRoom
17- import io.element.android.libraries.matrix.api.room.MessageEventType
1817import io.element.android.libraries.matrix.api.room.RoomMember
19- import io.element.android.libraries.matrix.api.room.isDm
20- import io.element.android.libraries.matrix.api.room.powerlevels.canBan
21- import io.element.android.libraries.matrix.api.room.powerlevels.canHandleKnockRequests
22- import io.element.android.libraries.matrix.api.room.powerlevels.canInvite
23- import io.element.android.libraries.matrix.api.room.powerlevels.canKick
24- import io.element.android.libraries.matrix.api.room.powerlevels.canRedactOther
25- import io.element.android.libraries.matrix.api.room.powerlevels.canRedactOwn
26- import io.element.android.libraries.matrix.api.room.powerlevels.canSendMessage
2718import io.element.android.libraries.matrix.ui.model.roleOf
2819
29- @Composable
30- fun BaseRoom.canSendMessageAsState (type : MessageEventType , updateKey : Long ): State <Boolean > {
31- return produceState(initialValue = true , key1 = updateKey) {
32- value = canSendMessage(type).getOrElse { true }
33- }
34- }
35-
36- @Composable
37- fun BaseRoom.canInviteAsState (updateKey : Long ): State <Boolean > {
38- return produceState(initialValue = false , key1 = updateKey) {
39- value = canInvite().getOrElse { false }
40- }
41- }
42-
43- @Composable
44- fun BaseRoom.canRedactOwnAsState (updateKey : Long ): State <Boolean > {
45- return produceState(initialValue = false , key1 = updateKey) {
46- value = canRedactOwn().getOrElse { false }
47- }
48- }
49-
50- @Composable
51- fun BaseRoom.canRedactOtherAsState (updateKey : Long ): State <Boolean > {
52- return produceState(initialValue = false , key1 = updateKey) {
53- value = canRedactOther().getOrElse { false }
54- }
55- }
56-
57- @Composable
58- fun BaseRoom.canCall (updateKey : Long ): State <Boolean > {
59- return produceState(initialValue = false , key1 = updateKey) {
60- value = canUserJoinCall(sessionId).getOrElse { false }
61- }
62- }
63-
64- @Composable
65- fun BaseRoom.canPinUnpin (updateKey : Long ): State <Boolean > {
66- return produceState(initialValue = false , key1 = updateKey) {
67- value = canUserPinUnpin(sessionId).getOrElse { false }
68- }
69- }
70-
71- @Composable
72- fun BaseRoom.isDmAsState (): State <Boolean > {
73- return produceState(initialValue = false ) {
74- roomInfoFlow.collect { value = it.isDm }
75- }
76- }
77-
78- @Composable
79- fun BaseRoom.canKickAsState (updateKey : Long ): State <Boolean > {
80- return produceState(initialValue = false , key1 = updateKey) {
81- value = canKick().getOrElse { false }
82- }
83- }
84-
85- @Composable
86- fun BaseRoom.canBanAsState (updateKey : Long ): State <Boolean > {
87- return produceState(initialValue = false , key1 = updateKey) {
88- value = canBan().getOrElse { false }
89- }
90- }
91-
92- @Composable
93- fun BaseRoom.canHandleKnockRequestsAsState (updateKey : Long ): State <Boolean > {
94- return produceState(initialValue = false , key1 = updateKey) {
95- value = canHandleKnockRequests().getOrElse { false }
96- }
97- }
98-
9920@Composable
10021fun BaseRoom.userPowerLevelAsState (updateKey : Long ): State <Long > {
10122 return produceState(initialValue = 0 , key1 = updateKey) {
0 commit comments