Skip to content

Commit 541a1d2

Browse files
committed
misc(power level) : remove old api
1 parent d654280 commit 541a1d2

File tree

2 files changed

+0
-133
lines changed
  • libraries
    • matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/room
    • matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room

2 files changed

+0
-133
lines changed

libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustBaseRoom.kt

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -186,60 +186,6 @@ class RustBaseRoom(
186186
}
187187
}
188188

189-
override suspend fun canUserInvite(userId: UserId): Result<Boolean> = withContext(roomDispatcher) {
190-
runCatchingExceptions {
191-
innerRoom.getPowerLevels().use { it.canUserInvite(userId.value) }
192-
}
193-
}
194-
195-
override suspend fun canUserKick(userId: UserId): Result<Boolean> = withContext(roomDispatcher) {
196-
runCatchingExceptions {
197-
innerRoom.getPowerLevels().use { it.canUserKick(userId.value) }
198-
}
199-
}
200-
201-
override suspend fun canUserBan(userId: UserId): Result<Boolean> = withContext(roomDispatcher) {
202-
runCatchingExceptions {
203-
innerRoom.getPowerLevels().use { it.canUserBan(userId.value) }
204-
}
205-
}
206-
207-
override suspend fun canUserRedactOwn(userId: UserId): Result<Boolean> = withContext(roomDispatcher) {
208-
runCatchingExceptions {
209-
innerRoom.getPowerLevels().use { it.canUserRedactOwn(userId.value) }
210-
}
211-
}
212-
213-
override suspend fun canUserRedactOther(userId: UserId): Result<Boolean> = withContext(roomDispatcher) {
214-
runCatchingExceptions {
215-
innerRoom.getPowerLevels().use { it.canUserRedactOther(userId.value) }
216-
}
217-
}
218-
219-
override suspend fun canUserSendState(userId: UserId, type: StateEventType): Result<Boolean> = withContext(roomDispatcher) {
220-
runCatchingExceptions {
221-
innerRoom.getPowerLevels().use { it.canUserSendState(userId.value, type.map()) }
222-
}
223-
}
224-
225-
override suspend fun canUserSendMessage(userId: UserId, type: MessageEventType): Result<Boolean> = withContext(roomDispatcher) {
226-
runCatchingExceptions {
227-
innerRoom.getPowerLevels().use { it.canUserSendMessage(userId.value, type.map()) }
228-
}
229-
}
230-
231-
override suspend fun canUserTriggerRoomNotification(userId: UserId): Result<Boolean> = withContext(roomDispatcher) {
232-
runCatchingExceptions {
233-
innerRoom.getPowerLevels().use { it.canUserTriggerRoomNotification(userId.value) }
234-
}
235-
}
236-
237-
override suspend fun canUserPinUnpin(userId: UserId): Result<Boolean> = withContext(roomDispatcher) {
238-
runCatchingExceptions {
239-
innerRoom.getPowerLevels().use { it.canUserPinUnpin(userId.value) }
240-
}
241-
}
242-
243189
override suspend fun clearEventCacheStorage(): Result<Unit> = withContext(roomDispatcher) {
244190
runCatchingExceptions {
245191
innerRoom.clearEventCacheStorage()

libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/room/MatrixRoomState.kt

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -14,88 +14,9 @@ import androidx.compose.runtime.collectAsState
1414
import androidx.compose.runtime.getValue
1515
import androidx.compose.runtime.produceState
1616
import io.element.android.libraries.matrix.api.room.BaseRoom
17-
import io.element.android.libraries.matrix.api.room.MessageEventType
1817
import 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
2718
import 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
10021
fun BaseRoom.userPowerLevelAsState(updateKey: Long): State<Long> {
10122
return produceState(initialValue = 0, key1 = updateKey) {

0 commit comments

Comments
 (0)