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
@@ -4700,6 +4700,76 @@ class ClientProxyMock: ClientProxyProtocol {
return resetIdentityReturnValue
}
}
//MARK: - userIdentity
var userIdentityForUnderlyingCallsCount = 0
var userIdentityForCallsCount: Int {
get {
if Thread.isMainThread {
return userIdentityForUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = userIdentityForUnderlyingCallsCount
}
return returnValue!
}
}
set {
if Thread.isMainThread {
userIdentityForUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
userIdentityForUnderlyingCallsCount = newValue
}
}
}
}
var userIdentityForCalled: Bool {
return userIdentityForCallsCount > 0
}
var userIdentityForReceivedUserID: String?
var userIdentityForReceivedInvocations: [String] = []
var userIdentityForUnderlyingReturnValue: Result<UserIdentity?, ClientProxyError>!
var userIdentityForReturnValue: Result<UserIdentity?, ClientProxyError>! {
get {
if Thread.isMainThread {
return userIdentityForUnderlyingReturnValue
} else {
var returnValue: Result<UserIdentity?, ClientProxyError>? = nil
DispatchQueue.main.sync {
returnValue = userIdentityForUnderlyingReturnValue
}
return returnValue!
}
}
set {
if Thread.isMainThread {
userIdentityForUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
userIdentityForUnderlyingReturnValue = newValue
}
}
}
}
var userIdentityForClosure: ((String) async -> Result<UserIdentity?, ClientProxyError>)?
func userIdentity(for userID: String) async -> Result<UserIdentity?, ClientProxyError> {
userIdentityForCallsCount += 1
userIdentityForReceivedUserID = userID
DispatchQueue.main.async {
self.userIdentityForReceivedInvocations.append(userID)
}
if let userIdentityForClosure = userIdentityForClosure {
return await userIdentityForClosure(userID)
} else {
return userIdentityForReturnValue
}
}
//MARK: - loadMediaContentForSource
var loadMediaContentForSourceThrowableError: Error?
@@ -6214,81 +6214,6 @@ open class EncryptionSDKMock: MatrixRustSDK.Encryption {
}
}
//MARK: - getUserIdentity
open var getUserIdentityUserIdThrowableError: Error?
var getUserIdentityUserIdUnderlyingCallsCount = 0
open var getUserIdentityUserIdCallsCount: Int {
get {
if Thread.isMainThread {
return getUserIdentityUserIdUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = getUserIdentityUserIdUnderlyingCallsCount
}
return returnValue!
}
}
set {
if Thread.isMainThread {
getUserIdentityUserIdUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
getUserIdentityUserIdUnderlyingCallsCount = newValue
}
}
}
}
open var getUserIdentityUserIdCalled: Bool {
return getUserIdentityUserIdCallsCount > 0
}
open var getUserIdentityUserIdReceivedUserId: String?
open var getUserIdentityUserIdReceivedInvocations: [String] = []
var getUserIdentityUserIdUnderlyingReturnValue: UserIdentity?
open var getUserIdentityUserIdReturnValue: UserIdentity? {
get {
if Thread.isMainThread {
return getUserIdentityUserIdUnderlyingReturnValue
} else {
var returnValue: UserIdentity?? = nil
DispatchQueue.main.sync {
returnValue = getUserIdentityUserIdUnderlyingReturnValue
}
return returnValue!
}
}
set {
if Thread.isMainThread {
getUserIdentityUserIdUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
getUserIdentityUserIdUnderlyingReturnValue = newValue
}
}
}
}
open var getUserIdentityUserIdClosure: ((String) async throws -> UserIdentity?)?
open override func getUserIdentity(userId: String) async throws -> UserIdentity? {
if let error = getUserIdentityUserIdThrowableError {
throw error
}
getUserIdentityUserIdCallsCount += 1
getUserIdentityUserIdReceivedUserId = userId
DispatchQueue.main.async {
self.getUserIdentityUserIdReceivedInvocations.append(userId)
}
if let getUserIdentityUserIdClosure = getUserIdentityUserIdClosure {
return try await getUserIdentityUserIdClosure(userId)
} else {
return getUserIdentityUserIdReturnValue
}
}
//MARK: - isLastDevice
open var isLastDeviceThrowableError: Error?
@@ -6753,6 +6678,81 @@ open class EncryptionSDKMock: MatrixRustSDK.Encryption {
}
}
//MARK: - userIdentity
open var userIdentityUserIdThrowableError: Error?
var userIdentityUserIdUnderlyingCallsCount = 0
open var userIdentityUserIdCallsCount: Int {
get {
if Thread.isMainThread {
return userIdentityUserIdUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = userIdentityUserIdUnderlyingCallsCount
}
return returnValue!
}
}
set {
if Thread.isMainThread {
userIdentityUserIdUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
userIdentityUserIdUnderlyingCallsCount = newValue
}
}
}
}
open var userIdentityUserIdCalled: Bool {
return userIdentityUserIdCallsCount > 0
}
open var userIdentityUserIdReceivedUserId: String?
open var userIdentityUserIdReceivedInvocations: [String] = []
var userIdentityUserIdUnderlyingReturnValue: UserIdentity?
open var userIdentityUserIdReturnValue: UserIdentity? {
get {
if Thread.isMainThread {
return userIdentityUserIdUnderlyingReturnValue
} else {
var returnValue: UserIdentity?? = nil
DispatchQueue.main.sync {
returnValue = userIdentityUserIdUnderlyingReturnValue
}
return returnValue!
}
}
set {
if Thread.isMainThread {
userIdentityUserIdUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
userIdentityUserIdUnderlyingReturnValue = newValue
}
}
}
}
open var userIdentityUserIdClosure: ((String) async throws -> UserIdentity?)?
open override func userIdentity(userId: String) async throws -> UserIdentity? {
if let error = userIdentityUserIdThrowableError {
throw error
}
userIdentityUserIdCallsCount += 1
userIdentityUserIdReceivedUserId = userId
DispatchQueue.main.async {
self.userIdentityUserIdReceivedInvocations.append(userId)
}
if let userIdentityUserIdClosure = userIdentityUserIdClosure {
return try await userIdentityUserIdClosure(userId)
} else {
return userIdentityUserIdReturnValue
}
}
//MARK: - verificationState
var verificationStateUnderlyingCallsCount = 0
@@ -18042,34 +18042,9 @@ open class TimelineSDKMock: MatrixRustSDK.Timeline {
}
open var editEventOrTransactionIdNewContentReceivedArguments: (eventOrTransactionId: EventOrTransactionId, newContent: EditedContent)?
open var editEventOrTransactionIdNewContentReceivedInvocations: [(eventOrTransactionId: EventOrTransactionId, newContent: EditedContent)] = []
open var editEventOrTransactionIdNewContentClosure: ((EventOrTransactionId, EditedContent) async throws -> Void)?
var editEventOrTransactionIdNewContentUnderlyingReturnValue: Bool!
open var editEventOrTransactionIdNewContentReturnValue: Bool! {
get {
if Thread.isMainThread {
return editEventOrTransactionIdNewContentUnderlyingReturnValue
} else {
var returnValue: Bool? = nil
DispatchQueue.main.sync {
returnValue = editEventOrTransactionIdNewContentUnderlyingReturnValue
}
return returnValue!
}
}
set {
if Thread.isMainThread {
editEventOrTransactionIdNewContentUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
editEventOrTransactionIdNewContentUnderlyingReturnValue = newValue
}
}
}
}
open var editEventOrTransactionIdNewContentClosure: ((EventOrTransactionId, EditedContent) async throws -> Bool)?
open override func edit(eventOrTransactionId: EventOrTransactionId, newContent: EditedContent) async throws -> Bool {
open override func edit(eventOrTransactionId: EventOrTransactionId, newContent: EditedContent) async throws {
if let error = editEventOrTransactionIdNewContentThrowableError {
throw error
}
@@ -18078,11 +18053,7 @@ open class TimelineSDKMock: MatrixRustSDK.Timeline {
DispatchQueue.main.async {
self.editEventOrTransactionIdNewContentReceivedInvocations.append((eventOrTransactionId: eventOrTransactionId, newContent: newContent))
}
if let editEventOrTransactionIdNewContentClosure = editEventOrTransactionIdNewContentClosure {
return try await editEventOrTransactionIdNewContentClosure(eventOrTransactionId, newContent)
} else {
return editEventOrTransactionIdNewContentReturnValue
}
try await editEventOrTransactionIdNewContentClosure?(eventOrTransactionId, newContent)
}
//MARK: - endPoll
@@ -20976,6 +20947,71 @@ open class UserIdentitySDKMock: MatrixRustSDK.UserIdentity {
fileprivate var pointer: UnsafeMutableRawPointer!
//MARK: - isVerified
var isVerifiedUnderlyingCallsCount = 0
open var isVerifiedCallsCount: Int {
get {
if Thread.isMainThread {
return isVerifiedUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = isVerifiedUnderlyingCallsCount
}
return returnValue!
}
}
set {
if Thread.isMainThread {
isVerifiedUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
isVerifiedUnderlyingCallsCount = newValue
}
}
}
}
open var isVerifiedCalled: Bool {
return isVerifiedCallsCount > 0
}
var isVerifiedUnderlyingReturnValue: Bool!
open var isVerifiedReturnValue: Bool! {
get {
if Thread.isMainThread {
return isVerifiedUnderlyingReturnValue
} else {
var returnValue: Bool? = nil
DispatchQueue.main.sync {
returnValue = isVerifiedUnderlyingReturnValue
}
return returnValue!
}
}
set {
if Thread.isMainThread {
isVerifiedUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
isVerifiedUnderlyingReturnValue = newValue
}
}
}
}
open var isVerifiedClosure: (() -> Bool)?
open override func isVerified() -> Bool {
isVerifiedCallsCount += 1
if let isVerifiedClosure = isVerifiedClosure {
return isVerifiedClosure()
} else {
return isVerifiedReturnValue
}
}
//MARK: - masterKey
var masterKeyUnderlyingCallsCount = 0