Merge pull request #4423 from element-hq/fix/display-user-verification-violation-on-top-app-bar-of-room-screen
Display user verification violation icon in DM rooms too
This commit is contained in:
commit
43cf8a11dd
10 changed files with 45 additions and 20 deletions
|
|
@ -187,13 +187,17 @@ class MessagesPresenter @AssistedInject constructor(
|
|||
|
||||
val membersState by room.membersStateFlow.collectAsState()
|
||||
val dmRoomMember by room.getDirectRoomMember(membersState)
|
||||
val roomMemberIdentityStateChanges = identityChangeState.roomMemberIdentityStateChanges
|
||||
|
||||
// TODO use `RoomInfo.isEncrypted` as a key here once it's available
|
||||
LifecycleResumeEffect(dmRoomMember) {
|
||||
LifecycleResumeEffect(dmRoomMember, roomMemberIdentityStateChanges) {
|
||||
if (room.isEncrypted) {
|
||||
val dmRoomMemberId = dmRoomMember?.userId
|
||||
localCoroutineScope.launch {
|
||||
dmRoomMemberId?.let { dmUserVerificationState = encryptionService.getUserIdentity(it).getOrNull() }
|
||||
dmRoomMemberId?.let { userId ->
|
||||
dmUserVerificationState = roomMemberIdentityStateChanges.find { it.identityRoomMember.userId == userId }?.identityState
|
||||
?: encryptionService.getUserIdentity(userId).getOrNull()
|
||||
}
|
||||
}
|
||||
}
|
||||
onPauseOrDispose {}
|
||||
|
|
|
|||
|
|
@ -81,7 +81,8 @@ open class MessagesStateProvider : PreviewParameterProvider<MessagesState> {
|
|||
currentPinnedMessageIndex = 0,
|
||||
),
|
||||
),
|
||||
aMessagesState(roomName = AsyncData.Success("A DM with a very looong name"), dmUserVerificationState = IdentityState.Verified)
|
||||
aMessagesState(roomName = AsyncData.Success("A DM with a very looong name"), dmUserVerificationState = IdentityState.Verified),
|
||||
aMessagesState(roomName = AsyncData.Success("A DM with a very looong name"), dmUserVerificationState = IdentityState.VerificationViolation),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ fun MessagesView(
|
|||
roomAvatar = state.roomAvatar.dataOrNull(),
|
||||
heroes = state.heroes,
|
||||
roomCallState = state.roomCallState,
|
||||
isDmUserVerified = state.dmUserVerificationState?.let { it == IdentityState.Verified },
|
||||
dmUserIdentityState = state.dmUserVerificationState,
|
||||
onBackClick = { hidingKeyboard { onBackClick() } },
|
||||
onRoomDetailsClick = { hidingKeyboard { onRoomDetailsClick() } },
|
||||
onJoinCallClick = onJoinCallClick,
|
||||
|
|
@ -458,7 +458,7 @@ private fun MessagesViewTopBar(
|
|||
roomAvatar: AvatarData?,
|
||||
heroes: ImmutableList<AvatarData>,
|
||||
roomCallState: RoomCallState,
|
||||
isDmUserVerified: Boolean?,
|
||||
dmUserIdentityState: IdentityState?,
|
||||
onRoomDetailsClick: () -> Unit,
|
||||
onJoinCallClick: () -> Unit,
|
||||
onBackClick: () -> Unit,
|
||||
|
|
@ -490,13 +490,24 @@ private fun MessagesViewTopBar(
|
|||
)
|
||||
}
|
||||
|
||||
if (isDmUserVerified == true) {
|
||||
Icon(
|
||||
modifier = Modifier.requiredWidthIn(min = 24.dp),
|
||||
imageVector = CompoundIcons.Verified(),
|
||||
tint = ElementTheme.colors.iconSuccessPrimary,
|
||||
contentDescription = null
|
||||
)
|
||||
when (dmUserIdentityState) {
|
||||
IdentityState.Verified -> {
|
||||
Icon(
|
||||
modifier = Modifier.requiredWidthIn(min = 16.dp),
|
||||
imageVector = CompoundIcons.Verified(),
|
||||
tint = ElementTheme.colors.iconSuccessPrimary,
|
||||
contentDescription = null,
|
||||
)
|
||||
}
|
||||
IdentityState.VerificationViolation -> {
|
||||
Icon(
|
||||
modifier = Modifier.requiredWidthIn(min = 16.dp),
|
||||
imageVector = CompoundIcons.ErrorSolid(),
|
||||
tint = ElementTheme.colors.iconCriticalPrimary,
|
||||
contentDescription = null,
|
||||
)
|
||||
}
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import androidx.compose.foundation.layout.Row
|
|||
import androidx.compose.foundation.layout.consumeWindowInsets
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.foundation.lazy.items
|
||||
|
|
@ -319,6 +320,7 @@ private fun RoomMemberListItem(
|
|||
when (roomMemberWithIdentity.identityState) {
|
||||
IdentityState.Verified -> {
|
||||
Icon(
|
||||
modifier = Modifier.size(20.dp),
|
||||
imageVector = CompoundIcons.Verified(),
|
||||
contentDescription = stringResource(CommonStrings.common_verified),
|
||||
tint = ElementTheme.colors.iconSuccessPrimary
|
||||
|
|
@ -326,6 +328,7 @@ private fun RoomMemberListItem(
|
|||
}
|
||||
IdentityState.VerificationViolation -> {
|
||||
Icon(
|
||||
modifier = Modifier.size(20.dp),
|
||||
imageVector = CompoundIcons.ErrorSolid(),
|
||||
contentDescription = stringResource(
|
||||
CommonStrings.crypto_identity_change_profile_pin_violation,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue