mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Generating SDK Mocks through the usage of swift run tools generate-sdk-mocks (#982)
* basic implementation, that works for now only with the local SDK * replaced a handmade mock with a generated mock
This commit is contained in:
@@ -18,7 +18,7 @@ import Combine
|
||||
import SwiftUI
|
||||
|
||||
struct InviteUsersScreenCoordinatorParameters {
|
||||
let selectedUsers: CurrentValuePublisher<[UserProfile], Never>
|
||||
let selectedUsers: CurrentValuePublisher<[UserProfileProxy], Never>
|
||||
let roomType: InviteUsersScreenRoomType
|
||||
let mediaProvider: MediaProviderProtocol
|
||||
let userDiscoveryService: UserDiscoveryServiceProtocol
|
||||
@@ -27,7 +27,7 @@ struct InviteUsersScreenCoordinatorParameters {
|
||||
enum InviteUsersScreenCoordinatorAction {
|
||||
case proceed
|
||||
case invite(users: [String])
|
||||
case toggleUser(UserProfile)
|
||||
case toggleUser(UserProfileProxy)
|
||||
}
|
||||
|
||||
final class InviteUsersScreenCoordinator: CoordinatorProtocol {
|
||||
|
||||
@@ -24,7 +24,7 @@ enum InviteUsersScreenErrorType: Error {
|
||||
enum InviteUsersScreenViewModelAction {
|
||||
case proceed
|
||||
case invite(users: [String])
|
||||
case toggleUser(UserProfile)
|
||||
case toggleUser(UserProfileProxy)
|
||||
}
|
||||
|
||||
enum InviteUsersScreenRoomType {
|
||||
@@ -37,7 +37,7 @@ struct InviteUsersScreenViewState: BindableState {
|
||||
|
||||
var usersSection: UserDiscoverySection = .init(type: .suggestions, users: [])
|
||||
|
||||
var selectedUsers: [UserProfile] = []
|
||||
var selectedUsers: [UserProfileProxy] = []
|
||||
var membershipState: [String: MembershipState] = .init()
|
||||
|
||||
var isSearching: Bool {
|
||||
@@ -50,16 +50,16 @@ struct InviteUsersScreenViewState: BindableState {
|
||||
|
||||
var scrollToLastID: String?
|
||||
|
||||
func isUserSelected(_ user: UserProfile) -> Bool {
|
||||
func isUserSelected(_ user: UserProfileProxy) -> Bool {
|
||||
isUserDisabled(user) || selectedUsers.contains { $0.userID == user.userID }
|
||||
}
|
||||
|
||||
func isUserDisabled(_ user: UserProfile) -> Bool {
|
||||
func isUserDisabled(_ user: UserProfileProxy) -> Bool {
|
||||
let membershipState = membershipState(user)
|
||||
return membershipState == .invite || membershipState == .join
|
||||
}
|
||||
|
||||
func membershipState(_ user: UserProfile) -> MembershipState? {
|
||||
func membershipState(_ user: UserProfileProxy) -> MembershipState? {
|
||||
membershipState[user.userID]
|
||||
}
|
||||
|
||||
@@ -87,5 +87,5 @@ struct InviteUsersScreenViewStateBindings {
|
||||
|
||||
enum InviteUsersScreenViewAction {
|
||||
case proceed
|
||||
case toggleUser(UserProfile)
|
||||
case toggleUser(UserProfileProxy)
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class InviteUsersScreenViewModel: InviteUsersScreenViewModelType, InviteUsersScr
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init(selectedUsers: CurrentValuePublisher<[UserProfile], Never>,
|
||||
init(selectedUsers: CurrentValuePublisher<[UserProfileProxy], Never>,
|
||||
roomType: InviteUsersScreenRoomType,
|
||||
mediaProvider: MediaProviderProtocol,
|
||||
userDiscoveryService: UserDiscoveryServiceProtocol) {
|
||||
@@ -85,7 +85,7 @@ class InviteUsersScreenViewModel: InviteUsersScreenViewModelType, InviteUsersScr
|
||||
@CancellableTask
|
||||
private var fetchUsersTask: Task<Void, Never>?
|
||||
|
||||
private func setupSubscriptions(selectedUsers: CurrentValuePublisher<[UserProfile], Never>) {
|
||||
private func setupSubscriptions(selectedUsers: CurrentValuePublisher<[UserProfileProxy], Never>) {
|
||||
context.$viewState
|
||||
.map(\.bindings.searchQuery)
|
||||
.debounceAndRemoveDuplicates()
|
||||
@@ -125,7 +125,7 @@ class InviteUsersScreenViewModel: InviteUsersScreenViewModelType, InviteUsersScr
|
||||
}
|
||||
}
|
||||
|
||||
private func handleResult(for sectionType: UserDiscoverySectionType, result: Result<[UserProfile], UserDiscoveryErrorType>) {
|
||||
private func handleResult(for sectionType: UserDiscoverySectionType, result: Result<[UserProfileProxy], UserDiscoveryErrorType>) {
|
||||
switch result {
|
||||
case .success(let users):
|
||||
state.usersSection = .init(type: sectionType, users: users)
|
||||
|
||||
@@ -123,7 +123,7 @@ struct InviteUsersScreen: View {
|
||||
.disabled(context.viewState.isActionDisabled)
|
||||
}
|
||||
|
||||
private func deselect(_ user: UserProfile) {
|
||||
private func deselect(_ user: UserProfileProxy) {
|
||||
context.send(viewAction: .toggleUser(user))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
import SwiftUI
|
||||
|
||||
struct InviteUsersScreenSelectedItem: View {
|
||||
let user: UserProfile
|
||||
let user: UserProfileProxy
|
||||
let imageProvider: ImageProviderProtocol?
|
||||
let dismissAction: () -> Void
|
||||
|
||||
|
||||
Reference in New Issue
Block a user