Format files.

This commit is contained in:
Benoit Marty 2023-07-18 23:05:12 +02:00
parent 403530a069
commit 456f4fba6b
2 changed files with 33 additions and 42 deletions

View file

@ -109,7 +109,7 @@ class MessagesPresenter @AssistedInject constructor(
val syncUpdateFlow = room.syncUpdateFlow.collectAsState() val syncUpdateFlow = room.syncUpdateFlow.collectAsState()
val userHasPermissionToSendMessage by room.canSendMessageAsState(type = MessageEventType.ROOM_MESSAGE, updateKey = syncUpdateFlow.value) val userHasPermissionToSendMessage by room.canSendMessageAsState(type = MessageEventType.ROOM_MESSAGE, updateKey = syncUpdateFlow.value)
val roomName by produceState(initialValue = room.displayName, key1 = syncUpdateFlow.value){ val roomName by produceState(initialValue = room.displayName, key1 = syncUpdateFlow.value) {
value = room.displayName value = room.displayName
} }
val roomAvatar by produceState(initialValue = room.avatarData(), key1 = syncUpdateFlow.value) { val roomAvatar by produceState(initialValue = room.avatarData(), key1 = syncUpdateFlow.value) {

View file

@ -199,19 +199,17 @@ class RustMatrixRoom(
} }
} }
override suspend fun userDisplayName(userId: UserId): Result<String?> = override suspend fun userDisplayName(userId: UserId): Result<String?> = withContext(roomDispatcher) {
withContext(roomDispatcher) { runCatching {
runCatching { innerRoom.memberDisplayName(userId.value)
innerRoom.memberDisplayName(userId.value)
}
} }
}
override suspend fun userAvatarUrl(userId: UserId): Result<String?> = override suspend fun userAvatarUrl(userId: UserId): Result<String?> = withContext(roomDispatcher) {
withContext(roomDispatcher) { runCatching {
runCatching { innerRoom.memberAvatarUrl(userId.value)
innerRoom.memberAvatarUrl(userId.value)
}
} }
}
override suspend fun sendMessage(message: String): Result<Unit> = withContext(roomDispatcher) { override suspend fun sendMessage(message: String): Result<Unit> = withContext(roomDispatcher) {
val transactionId = genTransactionId() val transactionId = genTransactionId()
@ -324,48 +322,42 @@ class RustMatrixRoom(
} }
} }
override suspend fun retrySendMessage(transactionId: TransactionId): Result<Unit> = override suspend fun retrySendMessage(transactionId: TransactionId): Result<Unit> = withContext(roomDispatcher) {
withContext(roomDispatcher) { runCatching {
runCatching { innerRoom.retrySend(transactionId.value)
innerRoom.retrySend(transactionId.value)
}
} }
}
override suspend fun cancelSend(transactionId: TransactionId): Result<Unit> = override suspend fun cancelSend(transactionId: TransactionId): Result<Unit> = withContext(roomDispatcher) {
withContext(roomDispatcher) { runCatching {
runCatching { innerRoom.cancelSend(transactionId.value)
innerRoom.cancelSend(transactionId.value)
}
} }
}
@OptIn(ExperimentalUnsignedTypes::class) @OptIn(ExperimentalUnsignedTypes::class)
override suspend fun updateAvatar(mimeType: String, data: ByteArray): Result<Unit> = override suspend fun updateAvatar(mimeType: String, data: ByteArray): Result<Unit> = withContext(roomDispatcher) {
withContext(roomDispatcher) { runCatching {
runCatching { innerRoom.uploadAvatar(mimeType, data.toUByteArray().toList())
innerRoom.uploadAvatar(mimeType, data.toUByteArray().toList())
}
} }
}
override suspend fun removeAvatar(): Result<Unit> = override suspend fun removeAvatar(): Result<Unit> = withContext(roomDispatcher) {
withContext(roomDispatcher) { runCatching {
runCatching { innerRoom.removeAvatar()
innerRoom.removeAvatar()
}
} }
}
override suspend fun setName(name: String): Result<Unit> = override suspend fun setName(name: String): Result<Unit> = withContext(roomDispatcher) {
withContext(roomDispatcher) { runCatching {
runCatching { innerRoom.setName(name)
innerRoom.setName(name)
}
} }
}
override suspend fun setTopic(topic: String): Result<Unit> = override suspend fun setTopic(topic: String): Result<Unit> = withContext(roomDispatcher) {
withContext(roomDispatcher) { runCatching {
runCatching { innerRoom.setTopic(topic)
innerRoom.setTopic(topic)
}
} }
}
private suspend fun fetchMembers() = withContext(roomDispatcher) { private suspend fun fetchMembers() = withContext(roomDispatcher) {
runCatching { runCatching {
@ -410,4 +402,3 @@ private suspend fun sendAttachment(handle: () -> SendAttachmentJoinHandle): Resu
} }
} }
} }