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:
Benoit Marty 2025-03-18 14:24:19 +01:00 committed by GitHub
commit 4bf9d9d43f
10 changed files with 45 additions and 20 deletions

View file

@ -187,13 +187,17 @@ class MessagesPresenter @AssistedInject constructor(
val membersState by room.membersStateFlow.collectAsState() val membersState by room.membersStateFlow.collectAsState()
val dmRoomMember by room.getDirectRoomMember(membersState) val dmRoomMember by room.getDirectRoomMember(membersState)
val roomMemberIdentityStateChanges = identityChangeState.roomMemberIdentityStateChanges
// TODO use `RoomInfo.isEncrypted` as a key here once it's available // TODO use `RoomInfo.isEncrypted` as a key here once it's available
LifecycleResumeEffect(dmRoomMember) { LifecycleResumeEffect(dmRoomMember, roomMemberIdentityStateChanges) {
if (room.isEncrypted) { if (room.isEncrypted) {
val dmRoomMemberId = dmRoomMember?.userId val dmRoomMemberId = dmRoomMember?.userId
localCoroutineScope.launch { 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 {} onPauseOrDispose {}

View file

@ -81,7 +81,8 @@ open class MessagesStateProvider : PreviewParameterProvider<MessagesState> {
currentPinnedMessageIndex = 0, 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),
) )
} }

View file

@ -191,7 +191,7 @@ fun MessagesView(
roomAvatar = state.roomAvatar.dataOrNull(), roomAvatar = state.roomAvatar.dataOrNull(),
heroes = state.heroes, heroes = state.heroes,
roomCallState = state.roomCallState, roomCallState = state.roomCallState,
isDmUserVerified = state.dmUserVerificationState?.let { it == IdentityState.Verified }, dmUserIdentityState = state.dmUserVerificationState,
onBackClick = { hidingKeyboard { onBackClick() } }, onBackClick = { hidingKeyboard { onBackClick() } },
onRoomDetailsClick = { hidingKeyboard { onRoomDetailsClick() } }, onRoomDetailsClick = { hidingKeyboard { onRoomDetailsClick() } },
onJoinCallClick = onJoinCallClick, onJoinCallClick = onJoinCallClick,
@ -458,7 +458,7 @@ private fun MessagesViewTopBar(
roomAvatar: AvatarData?, roomAvatar: AvatarData?,
heroes: ImmutableList<AvatarData>, heroes: ImmutableList<AvatarData>,
roomCallState: RoomCallState, roomCallState: RoomCallState,
isDmUserVerified: Boolean?, dmUserIdentityState: IdentityState?,
onRoomDetailsClick: () -> Unit, onRoomDetailsClick: () -> Unit,
onJoinCallClick: () -> Unit, onJoinCallClick: () -> Unit,
onBackClick: () -> Unit, onBackClick: () -> Unit,
@ -490,13 +490,24 @@ private fun MessagesViewTopBar(
) )
} }
if (isDmUserVerified == true) { when (dmUserIdentityState) {
Icon( IdentityState.Verified -> {
modifier = Modifier.requiredWidthIn(min = 24.dp), Icon(
imageVector = CompoundIcons.Verified(), modifier = Modifier.requiredWidthIn(min = 16.dp),
tint = ElementTheme.colors.iconSuccessPrimary, imageVector = CompoundIcons.Verified(),
contentDescription = null 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
} }
} }
}, },

View file

@ -22,6 +22,7 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.consumeWindowInsets import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
@ -319,6 +320,7 @@ private fun RoomMemberListItem(
when (roomMemberWithIdentity.identityState) { when (roomMemberWithIdentity.identityState) {
IdentityState.Verified -> { IdentityState.Verified -> {
Icon( Icon(
modifier = Modifier.size(20.dp),
imageVector = CompoundIcons.Verified(), imageVector = CompoundIcons.Verified(),
contentDescription = stringResource(CommonStrings.common_verified), contentDescription = stringResource(CommonStrings.common_verified),
tint = ElementTheme.colors.iconSuccessPrimary tint = ElementTheme.colors.iconSuccessPrimary
@ -326,6 +328,7 @@ private fun RoomMemberListItem(
} }
IdentityState.VerificationViolation -> { IdentityState.VerificationViolation -> {
Icon( Icon(
modifier = Modifier.size(20.dp),
imageVector = CompoundIcons.ErrorSolid(), imageVector = CompoundIcons.ErrorSolid(),
contentDescription = stringResource( contentDescription = stringResource(
CommonStrings.crypto_identity_change_profile_pin_violation, CommonStrings.crypto_identity_change_profile_pin_violation,

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:250111eb95059839f71392dbfe683e7141825bb901b880ab402a412eb0a2edc0 oid sha256:b3387b50f6e1c50831f802140d125e633c028183a26527a67b2eeb11b17b94a0
size 60477 size 60224

View file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:bc7b967eb01668be02cab6ce6f77994622e94cf7d44da0e6b5996d2348f43108
size 60118

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:70f7e53cdeebda6fcbf0b9e542323eff9333f01acb822607b1bfeb784a5a61c2 oid sha256:8a0a77633d8d2bfe5f29cd772525769e4dfa613518408db8dfe8a27cf680da9f
size 59960 size 59715

View file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e7b1d184e7ef2e9324bd5e4b1e6b6e27521a9d9a50c12210b55594919670ee24
size 59657

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:a532a73c1c1d7c72503ca75f3f9863a3e4e073a0cc780ec05483e5c3001bd405 oid sha256:dc12de5ab3944ab1e5ac3d352bbac286d44ed4a5e67cd040309a7a32b1cbd9d1
size 45665 size 45438

View file

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1 version https://git-lfs.github.com/spec/v1
oid sha256:af97cc1cda5eab600630181788cbbd7ce6f4db3c18d6f6b5c44519f1a4e0b1e0 oid sha256:d24fb38f4cf8e0c8194abbbe1feca02b9515f4fe12db03f05730c2aab2a0c1e9
size 45622 size 45433