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 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) 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 data class Voice(val text: String) : SendMode
} }
sealed class CanSendStatus { sealed interface CanSendStatus {
object Allowed : CanSendStatus() object Allowed : CanSendStatus
object NoPermission : CanSendStatus() object NoPermission : CanSendStatus
data class UnSupportedE2eAlgorithm(val algorithm: String?) : CanSendStatus() data class UnSupportedE2eAlgorithm(val algorithm: String?) : CanSendStatus
} }
fun CanSendStatus.boolean(): Boolean { fun CanSendStatus.boolean(): Boolean {

View File

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