Code review

This commit is contained in:
Valere 2021-12-16 09:25:22 +01:00
parent 6b05e7a6bb
commit 38fbfad8d5
3 changed files with 11 additions and 7 deletions

View File

@ -27,7 +27,10 @@ interface RoomCryptoService {
fun shouldEncryptForInvitedMembers(): Boolean
/**
* Enable encryption of the room
* Enable encryption of the room.
* @param Use force to ensure that this algorithm will be used. Otherwise this call
* will throw if encryption is already setup or if the algorithm is not supported. Only to
* be used by admins to fix misconfigured encryption.
*/
suspend fun enableEncryption(algorithm: String = MXCRYPTO_ALGORITHM_MEGOLM, force: Boolean = false)

View File

@ -43,10 +43,10 @@ sealed interface SendMode {
data class Voice(val text: String) : SendMode
}
sealed class CanSendStatus {
object Allowed : CanSendStatus()
object NoPermission : CanSendStatus()
data class UnSupportedE2eAlgorithm(val algorithm: String?) : CanSendStatus()
sealed interface CanSendStatus {
object Allowed : CanSendStatus
object NoPermission : CanSendStatus
data class UnSupportedE2eAlgorithm(val algorithm: String?) : CanSendStatus
}
fun CanSendStatus.boolean(): Boolean {

View File

@ -71,10 +71,10 @@ class RoomProfileViewModel @AssistedInject constructor(
observeRoomCreateContent(flowRoom)
observeBannedRoomMembers(flowRoom)
observePermissions()
obeservePowerLevels()
observePowerLevels()
}
private fun obeservePowerLevels() {
private fun observePowerLevels() {
val powerLevelsContentLive = PowerLevelsFlowFactory(room).createFlow()
powerLevelsContentLive
.onEach {
@ -208,6 +208,7 @@ class RoomProfileViewModel @AssistedInject constructor(
room.enableEncryption(force = true)
} catch (failure: Throwable) {
Timber.e(failure, "Failed to restore encryption state in room ${room.roomId}")
_viewEvents.post(RoomProfileViewEvents.Failure(failure))
} finally {
_viewEvents.post(RoomProfileViewEvents.DismissLoading)
}