Show a verification badge on the Room Member/User Profile screens. (#3427)

* Add a badge for verified users/room members.

* Reorder subviews.

* Add a (disabled) button to verify other users.

* PR comments.

* Update the SDK.

* Adopt the SDK changes introduced in matrix-rust-sdk/pull/4100

---------

Co-authored-by: Stefan Ceriu <stefan.ceriu@gmail.com>
This commit is contained in:
Doug
2024-10-21 16:07:19 +01:00
committed by GitHub
parent a0c81cf393
commit a4ea552a83
50 changed files with 522 additions and 275 deletions
@@ -42,24 +42,8 @@ class UserProfileScreenViewModel: UserProfileScreenViewModelType, UserProfileScr
showLoadingIndicator(allowsInteraction: true)
Task {
defer {
hideLoadingIndicator()
}
switch await clientProxy.profile(for: userID) {
case .success(let userProfile):
state.userProfile = userProfile
state.permalink = (try? matrixToUserPermalink(userId: userID)).flatMap(URL.init(string:))
switch await clientProxy.directRoomForUserID(userProfile.userID) {
case .success(let roomID):
state.dmRoomID = roomID
case .failure:
break
}
case .failure(let error):
state.bindings.alertInfo = .init(id: .unknown)
MXLog.error("Failed to find user profile: \(error)")
}
await loadProfile()
hideLoadingIndicator()
}
}
@@ -87,6 +71,32 @@ class UserProfileScreenViewModel: UserProfileScreenViewModelType, UserProfileScr
// MARK: - Private
private func loadProfile() async {
async let profileResult = clientProxy.profile(for: state.userID)
async let identityResult = clientProxy.userIdentity(for: state.userID)
switch await profileResult {
case .success(let userProfile):
state.userProfile = userProfile
state.permalink = (try? matrixToUserPermalink(userId: state.userID)).flatMap(URL.init(string:))
switch await clientProxy.directRoomForUserID(userProfile.userID) {
case .success(let roomID):
state.dmRoomID = roomID
case .failure:
break
}
case .failure(let error):
state.bindings.alertInfo = .init(id: .unknown)
MXLog.error("Failed to find user profile: \(error)")
}
if case let .success(.some(identity)) = await identityResult {
state.isVerified = identity.isVerified()
} else {
MXLog.error("Failed to find the user's identity.")
}
}
private func displayFullScreenAvatar(_ url: URL) async {
guard let userProfile = state.userProfile else { fatalError() }