Tapping on user avatar/name in the timeline opens the room member details (#1020)

* Implementation completed

* changelog

* code improvement

* Apply suggestions from code review

Co-authored-by: Stefan Ceriu <stefanc@matrix.org>

* pr suggestions

---------

Co-authored-by: Stefan Ceriu <stefanc@matrix.org>
This commit is contained in:
Mauro
2023-06-06 10:46:04 +02:00
committed by GitHub
parent ea4aa943e0
commit 4b2aba9367
24 changed files with 371 additions and 61 deletions
@@ -4,8 +4,9 @@
// swiftlint:disable all
import Combine
import Foundation
import MatrixRustSDK
import SwiftUI
import AnalyticsEvents
import MatrixRustSDK
class AnalyticsClientMock: AnalyticsClientProtocol {
var isRunning: Bool {
get { return underlyingIsRunning }
@@ -813,6 +814,27 @@ class RoomProxyMock: RoomProxyProtocol {
updateMembersCallsCount += 1
await updateMembersClosure?()
}
//MARK: - getMember
var getMemberUserIDCallsCount = 0
var getMemberUserIDCalled: Bool {
return getMemberUserIDCallsCount > 0
}
var getMemberUserIDReceivedUserID: String?
var getMemberUserIDReceivedInvocations: [String] = []
var getMemberUserIDReturnValue: Result<RoomMemberProxyProtocol, RoomProxyError>!
var getMemberUserIDClosure: ((String) async -> Result<RoomMemberProxyProtocol, RoomProxyError>)?
func getMember(userID: String) async -> Result<RoomMemberProxyProtocol, RoomProxyError> {
getMemberUserIDCallsCount += 1
getMemberUserIDReceivedUserID = userID
getMemberUserIDReceivedInvocations.append(userID)
if let getMemberUserIDClosure = getMemberUserIDClosure {
return await getMemberUserIDClosure(userID)
} else {
return getMemberUserIDReturnValue
}
}
//MARK: - inviter
var inviterCallsCount = 0
@@ -1121,4 +1143,93 @@ class UserDiscoveryServiceMock: UserDiscoveryServiceProtocol {
}
}
}
class UserIndicatorControllerMock: UserIndicatorControllerProtocol {
var alertInfo: AlertInfo<UUID>?
//MARK: - submitIndicator
var submitIndicatorCallsCount = 0
var submitIndicatorCalled: Bool {
return submitIndicatorCallsCount > 0
}
var submitIndicatorReceivedIndicator: UserIndicator?
var submitIndicatorReceivedInvocations: [UserIndicator] = []
var submitIndicatorClosure: ((UserIndicator) -> Void)?
func submitIndicator(_ indicator: UserIndicator) {
submitIndicatorCallsCount += 1
submitIndicatorReceivedIndicator = indicator
submitIndicatorReceivedInvocations.append(indicator)
submitIndicatorClosure?(indicator)
}
//MARK: - retractIndicatorWithId
var retractIndicatorWithIdCallsCount = 0
var retractIndicatorWithIdCalled: Bool {
return retractIndicatorWithIdCallsCount > 0
}
var retractIndicatorWithIdReceivedId: String?
var retractIndicatorWithIdReceivedInvocations: [String] = []
var retractIndicatorWithIdClosure: ((String) -> Void)?
func retractIndicatorWithId(_ id: String) {
retractIndicatorWithIdCallsCount += 1
retractIndicatorWithIdReceivedId = id
retractIndicatorWithIdReceivedInvocations.append(id)
retractIndicatorWithIdClosure?(id)
}
//MARK: - retractAllIndicators
var retractAllIndicatorsCallsCount = 0
var retractAllIndicatorsCalled: Bool {
return retractAllIndicatorsCallsCount > 0
}
var retractAllIndicatorsClosure: (() -> Void)?
func retractAllIndicators() {
retractAllIndicatorsCallsCount += 1
retractAllIndicatorsClosure?()
}
//MARK: - start
var startCallsCount = 0
var startCalled: Bool {
return startCallsCount > 0
}
var startClosure: (() -> Void)?
func start() {
startCallsCount += 1
startClosure?()
}
//MARK: - stop
var stopCallsCount = 0
var stopCalled: Bool {
return stopCallsCount > 0
}
var stopClosure: (() -> Void)?
func stop() {
stopCallsCount += 1
stopClosure?()
}
//MARK: - toPresentable
var toPresentableCallsCount = 0
var toPresentableCalled: Bool {
return toPresentableCallsCount > 0
}
var toPresentableReturnValue: AnyView!
var toPresentableClosure: (() -> AnyView)?
func toPresentable() -> AnyView {
toPresentableCallsCount += 1
if let toPresentableClosure = toPresentableClosure {
return toPresentableClosure()
} else {
return toPresentableReturnValue
}
}
}
// swiftlint:enable all
@@ -0,0 +1,28 @@
//
// Copyright 2023 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Combine
import Foundation
extension UserIndicatorControllerMock {
static var `default`: UserIndicatorControllerMock {
let mock = UserIndicatorControllerMock()
mock.submitIndicatorClosure = { _ in }
mock.retractIndicatorWithIdClosure = { _ in }
mock.retractAllIndicatorsClosure = { }
return mock
}
}