mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00
Small recently visited room tweaks following PR review
This commit is contained in:
parent
5221e9fb5d
commit
d996c69a66
@ -1010,11 +1010,11 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
||||
|
||||
let stackCoordinator = NavigationStackCoordinator()
|
||||
let inviteParameters = InviteUsersScreenCoordinatorParameters(clientProxy: userSession.clientProxy,
|
||||
selectedUsers: .init(selectedUsersSubject),
|
||||
roomType: .room(roomProxy: roomProxy),
|
||||
mediaProvider: userSession.mediaProvider,
|
||||
userDiscoveryService: UserDiscoveryService(clientProxy: userSession.clientProxy),
|
||||
userIndicatorController: userIndicatorController,
|
||||
selectedUsers: .init(selectedUsersSubject),
|
||||
roomType: .room(roomProxy: roomProxy))
|
||||
userIndicatorController: userIndicatorController)
|
||||
|
||||
let coordinator = InviteUsersScreenCoordinator(parameters: inviteParameters)
|
||||
stackCoordinator.setRootCoordinator(coordinator)
|
||||
|
@ -19,12 +19,11 @@ import SwiftUI
|
||||
|
||||
struct InviteUsersScreenCoordinatorParameters {
|
||||
let clientProxy: ClientProxyProtocol
|
||||
let selectedUsers: CurrentValuePublisher<[UserProfileProxy], Never>
|
||||
let roomType: InviteUsersScreenRoomType
|
||||
let mediaProvider: MediaProviderProtocol
|
||||
let userDiscoveryService: UserDiscoveryServiceProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
|
||||
let selectedUsers: CurrentValuePublisher<[UserProfileProxy], Never>
|
||||
let roomType: InviteUsersScreenRoomType
|
||||
}
|
||||
|
||||
enum InviteUsersScreenCoordinatorAction {
|
||||
@ -45,11 +44,11 @@ final class InviteUsersScreenCoordinator: CoordinatorProtocol {
|
||||
|
||||
init(parameters: InviteUsersScreenCoordinatorParameters) {
|
||||
viewModel = InviteUsersScreenViewModel(clientProxy: parameters.clientProxy,
|
||||
selectedUsers: parameters.selectedUsers,
|
||||
roomType: parameters.roomType,
|
||||
mediaProvider: parameters.mediaProvider,
|
||||
userDiscoveryService: parameters.userDiscoveryService,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
selectedUsers: parameters.selectedUsers,
|
||||
roomType: parameters.roomType)
|
||||
userIndicatorController: parameters.userIndicatorController)
|
||||
}
|
||||
|
||||
func start() {
|
||||
|
@ -34,17 +34,16 @@ class InviteUsersScreenViewModel: InviteUsersScreenViewModelType, InviteUsersScr
|
||||
}
|
||||
|
||||
init(clientProxy: ClientProxyProtocol,
|
||||
selectedUsers: CurrentValuePublisher<[UserProfileProxy], Never>,
|
||||
roomType: InviteUsersScreenRoomType,
|
||||
mediaProvider: MediaProviderProtocol,
|
||||
userDiscoveryService: UserDiscoveryServiceProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol,
|
||||
selectedUsers: CurrentValuePublisher<[UserProfileProxy], Never>,
|
||||
roomType: InviteUsersScreenRoomType) {
|
||||
userIndicatorController: UserIndicatorControllerProtocol) {
|
||||
self.clientProxy = clientProxy
|
||||
self.roomType = roomType
|
||||
self.userDiscoveryService = userDiscoveryService
|
||||
self.userIndicatorController = userIndicatorController
|
||||
|
||||
self.roomType = roomType
|
||||
|
||||
super.init(initialViewState: InviteUsersScreenViewState(selectedUsers: selectedUsers.value, isCreatingRoom: roomType.isCreatingRoom), imageProvider: mediaProvider)
|
||||
|
||||
setupSubscriptions(selectedUsers: selectedUsers)
|
||||
|
@ -161,11 +161,11 @@ struct InviteUsersScreen_Previews: PreviewProvider, TestablePreview {
|
||||
let userDiscoveryService = UserDiscoveryServiceMock()
|
||||
userDiscoveryService.searchProfilesWithReturnValue = .success([.mockAlice])
|
||||
return InviteUsersScreenViewModel(clientProxy: ClientProxyMock(.init()),
|
||||
selectedUsers: .init([]),
|
||||
roomType: .draft,
|
||||
mediaProvider: MockMediaProvider(),
|
||||
userDiscoveryService: userDiscoveryService,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
selectedUsers: .init([]),
|
||||
roomType: .draft)
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
}()
|
||||
|
||||
static var previews: some View {
|
||||
|
@ -85,11 +85,11 @@ final class StartChatScreenCoordinator: CoordinatorProtocol {
|
||||
|
||||
private func presentInviteUsersScreen() {
|
||||
let inviteParameters = InviteUsersScreenCoordinatorParameters(clientProxy: parameters.userSession.clientProxy,
|
||||
selectedUsers: selectedUsersPublisher,
|
||||
roomType: .draft,
|
||||
mediaProvider: parameters.userSession.mediaProvider,
|
||||
userDiscoveryService: parameters.userDiscoveryService,
|
||||
userIndicatorController: parameters.userIndicatorController,
|
||||
selectedUsers: selectedUsersPublisher,
|
||||
roomType: .draft)
|
||||
userIndicatorController: parameters.userIndicatorController)
|
||||
let coordinator = InviteUsersScreenCoordinator(parameters: inviteParameters)
|
||||
coordinator.actions.sink { [weak self] action in
|
||||
guard let self else { return }
|
||||
|
@ -16,8 +16,10 @@
|
||||
|
||||
import Combine
|
||||
import CryptoKit
|
||||
import Foundation
|
||||
import OrderedCollections
|
||||
|
||||
import MatrixRustSDK
|
||||
import SwiftUI
|
||||
|
||||
class ClientProxy: ClientProxyProtocol {
|
||||
private let client: ClientProtocol
|
||||
@ -625,7 +627,7 @@ class ClientProxy: ClientProxyProtocol {
|
||||
return []
|
||||
}
|
||||
|
||||
var users = [UserProfileProxy]()
|
||||
var users: OrderedSet<UserProfileProxy> = []
|
||||
|
||||
for roomID in roomIdentifiers {
|
||||
guard let room = await roomForIdentifier(roomID),
|
||||
@ -639,12 +641,12 @@ class ClientProxy: ClientProxyProtocol {
|
||||
|
||||
// Return early to avoid unnecessary work
|
||||
if users.count >= maxResultsToReturn {
|
||||
return users
|
||||
return users.elements
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return users
|
||||
return users.elements
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
@ -17,7 +17,7 @@
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
struct UserProfileProxy: Equatable {
|
||||
struct UserProfileProxy: Equatable, Hashable {
|
||||
let userID: String
|
||||
let displayName: String?
|
||||
let avatarURL: URL?
|
||||
|
@ -99,11 +99,11 @@ class InviteUsersScreenViewModelTests: XCTestCase {
|
||||
userDiscoveryService.searchProfilesWithReturnValue = .success([])
|
||||
usersSubject.send([])
|
||||
let viewModel = InviteUsersScreenViewModel(clientProxy: ClientProxyMock(.init()),
|
||||
selectedUsers: usersSubject.asCurrentValuePublisher(),
|
||||
roomType: roomType,
|
||||
mediaProvider: MockMediaProvider(),
|
||||
userDiscoveryService: userDiscoveryService,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
selectedUsers: usersSubject.asCurrentValuePublisher(),
|
||||
roomType: roomType)
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
viewModel.state.usersSection = .init(type: .suggestions, users: [.mockAlice, .mockBob, .mockCharlie])
|
||||
self.viewModel = viewModel
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user