From 7a623bb02ecfca8656be6462a84293bb344133b4 Mon Sep 17 00:00:00 2001 From: Stefan Ceriu Date: Mon, 1 Apr 2024 11:37:39 +0300 Subject: [PATCH] Fixes #2624, fixes #2625 - Add user suggestions in the create room flows. --- .../RoomFlowCoordinator.swift | 7 ++- .../UserSessionFlowCoordinator.swift | 4 ++ ElementX/Sources/Mocks/ClientProxyMock.swift | 4 ++ .../Mocks/Generated/GeneratedMocks.swift | 57 ++++++++++++++++++- .../Mocks/Generated/SDKGeneratedMocks.swift | 43 +++++++++++++- .../InviteUsersScreenCoordinator.swift | 13 +++-- .../InviteUsersScreenViewModel.swift | 49 ++++++++++------ .../View/InviteUsersScreen.swift | 7 ++- .../StartChatScreenCoordinator.swift | 7 ++- .../StartChatScreenViewModel.swift | 32 +++++++---- .../Sources/Services/Client/ClientProxy.swift | 55 +++++++++++++++++- .../Services/Client/ClientProxyProtocol.swift | 9 +++ .../Sources/InviteUsersViewModelTests.swift | 8 ++- UnitTests/Sources/LoggingTests.swift | 7 +-- 14 files changed, 247 insertions(+), 55 deletions(-) diff --git a/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift index 793df92990..5886799a33 100644 --- a/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift @@ -985,11 +985,12 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol { let selectedUsersSubject: CurrentValueSubject<[UserProfileProxy], Never> = .init([]) let stackCoordinator = NavigationStackCoordinator() - let inviteParameters = InviteUsersScreenCoordinatorParameters(selectedUsers: .init(selectedUsersSubject), - roomType: .room(roomProxy: roomProxy), + let inviteParameters = InviteUsersScreenCoordinatorParameters(clientProxy: userSession.clientProxy, mediaProvider: userSession.mediaProvider, userDiscoveryService: UserDiscoveryService(clientProxy: userSession.clientProxy), - userIndicatorController: userIndicatorController) + userIndicatorController: userIndicatorController, + selectedUsers: .init(selectedUsersSubject), + roomType: .room(roomProxy: roomProxy)) let coordinator = InviteUsersScreenCoordinator(parameters: inviteParameters) stackCoordinator.setRootCoordinator(coordinator) diff --git a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift index 39ea605a97..31f2d15be7 100644 --- a/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift +++ b/ElementX/Sources/FlowCoordinators/UserSessionFlowCoordinator.swift @@ -459,6 +459,10 @@ class UserSessionFlowCoordinator: FlowCoordinatorProtocol { if case .invitesScreen = stateMachine.state, availableInvitesCount == 1 { dismissInvitesList(animated: true) } + + Task { + await userSession.clientProxy.trackRecentlyVisitedRoom(roomID) + } } private func tearDownRoomFlow(animated: Bool) { diff --git a/ElementX/Sources/Mocks/ClientProxyMock.swift b/ElementX/Sources/Mocks/ClientProxyMock.swift index a61295d32f..268ac0162c 100644 --- a/ElementX/Sources/Mocks/ClientProxyMock.swift +++ b/ElementX/Sources/Mocks/ClientProxyMock.swift @@ -69,6 +69,10 @@ extension ClientProxyMock { ignoreUserReturnValue = .success(()) unignoreUserReturnValue = .success(()) + trackRecentlyVisitedRoomReturnValue = .success(()) + recentlyVisitedRoomsReturnValue = .success([]) + recentConversationCounterpartsReturnValue = [] + loadMediaContentForSourceThrowableError = ClientProxyError.failedLoadingMedia loadMediaThumbnailForSourceWidthHeightThrowableError = ClientProxyError.failedLoadingMedia loadMediaFileForSourceBodyThrowableError = ClientProxyError.failedLoadingMedia diff --git a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift index 6d2cea4a15..e8c155e426 100644 --- a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift +++ b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift @@ -1,4 +1,4 @@ -// Generated using Sourcery 2.1.8 — https://github.com/krzysztofzablocki/Sourcery +// Generated using Sourcery 2.2.2 — https://github.com/krzysztofzablocki/Sourcery // DO NOT EDIT // swiftlint:disable all @@ -1211,6 +1211,61 @@ class ClientProxyMock: ClientProxyProtocol { return unignoreUserReturnValue } } + //MARK: - trackRecentlyVisitedRoom + + var trackRecentlyVisitedRoomCallsCount = 0 + var trackRecentlyVisitedRoomCalled: Bool { + return trackRecentlyVisitedRoomCallsCount > 0 + } + var trackRecentlyVisitedRoomReceivedRoomID: String? + var trackRecentlyVisitedRoomReceivedInvocations: [String] = [] + var trackRecentlyVisitedRoomReturnValue: Result! + var trackRecentlyVisitedRoomClosure: ((String) async -> Result)? + + func trackRecentlyVisitedRoom(_ roomID: String) async -> Result { + trackRecentlyVisitedRoomCallsCount += 1 + trackRecentlyVisitedRoomReceivedRoomID = roomID + trackRecentlyVisitedRoomReceivedInvocations.append(roomID) + if let trackRecentlyVisitedRoomClosure = trackRecentlyVisitedRoomClosure { + return await trackRecentlyVisitedRoomClosure(roomID) + } else { + return trackRecentlyVisitedRoomReturnValue + } + } + //MARK: - recentlyVisitedRooms + + var recentlyVisitedRoomsCallsCount = 0 + var recentlyVisitedRoomsCalled: Bool { + return recentlyVisitedRoomsCallsCount > 0 + } + var recentlyVisitedRoomsReturnValue: Result<[String], ClientProxyError>! + var recentlyVisitedRoomsClosure: (() async -> Result<[String], ClientProxyError>)? + + func recentlyVisitedRooms() async -> Result<[String], ClientProxyError> { + recentlyVisitedRoomsCallsCount += 1 + if let recentlyVisitedRoomsClosure = recentlyVisitedRoomsClosure { + return await recentlyVisitedRoomsClosure() + } else { + return recentlyVisitedRoomsReturnValue + } + } + //MARK: - recentConversationCounterparts + + var recentConversationCounterpartsCallsCount = 0 + var recentConversationCounterpartsCalled: Bool { + return recentConversationCounterpartsCallsCount > 0 + } + var recentConversationCounterpartsReturnValue: [UserProfileProxy]! + var recentConversationCounterpartsClosure: (() async -> [UserProfileProxy])? + + func recentConversationCounterparts() async -> [UserProfileProxy] { + recentConversationCounterpartsCallsCount += 1 + if let recentConversationCounterpartsClosure = recentConversationCounterpartsClosure { + return await recentConversationCounterpartsClosure() + } else { + return recentConversationCounterpartsReturnValue + } + } //MARK: - loadMediaContentForSource var loadMediaContentForSourceThrowableError: Error? diff --git a/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift b/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift index 15b1129ff6..90e98574e8 100644 --- a/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift +++ b/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift @@ -1,4 +1,4 @@ -// Generated using Sourcery 2.1.7 — https://github.com/krzysztofzablocki/Sourcery +// Generated using Sourcery 2.1.8 — https://github.com/krzysztofzablocki/Sourcery // DO NOT EDIT // swiftlint:disable all @@ -344,6 +344,27 @@ class SDKClientMock: SDKClientProtocol { return getProfileUserIdReturnValue } } + //MARK: - getRecentlyVisitedRooms + + public var getRecentlyVisitedRoomsThrowableError: Error? + public var getRecentlyVisitedRoomsCallsCount = 0 + public var getRecentlyVisitedRoomsCalled: Bool { + return getRecentlyVisitedRoomsCallsCount > 0 + } + public var getRecentlyVisitedRoomsReturnValue: [String]! + public var getRecentlyVisitedRoomsClosure: (() async throws -> [String])? + + public func getRecentlyVisitedRooms() async throws -> [String] { + if let error = getRecentlyVisitedRoomsThrowableError { + throw error + } + getRecentlyVisitedRoomsCallsCount += 1 + if let getRecentlyVisitedRoomsClosure = getRecentlyVisitedRoomsClosure { + return try await getRecentlyVisitedRoomsClosure() + } else { + return getRecentlyVisitedRoomsReturnValue + } + } //MARK: - getSessionVerificationController public var getSessionVerificationControllerThrowableError: Error? @@ -749,6 +770,26 @@ class SDKClientMock: SDKClientProtocol { return syncServiceReturnValue } } + //MARK: - trackRecentlyVisitedRoom + + public var trackRecentlyVisitedRoomRoomThrowableError: Error? + public var trackRecentlyVisitedRoomRoomCallsCount = 0 + public var trackRecentlyVisitedRoomRoomCalled: Bool { + return trackRecentlyVisitedRoomRoomCallsCount > 0 + } + public var trackRecentlyVisitedRoomRoomReceivedRoom: String? + public var trackRecentlyVisitedRoomRoomReceivedInvocations: [String] = [] + public var trackRecentlyVisitedRoomRoomClosure: ((String) async throws -> Void)? + + public func trackRecentlyVisitedRoom(room: String) async throws { + if let error = trackRecentlyVisitedRoomRoomThrowableError { + throw error + } + trackRecentlyVisitedRoomRoomCallsCount += 1 + trackRecentlyVisitedRoomRoomReceivedRoom = room + trackRecentlyVisitedRoomRoomReceivedInvocations.append(room) + try await trackRecentlyVisitedRoomRoomClosure?(room) + } //MARK: - unignoreUser public var unignoreUserUserIdThrowableError: Error? diff --git a/ElementX/Sources/Screens/InviteUsersScreen/InviteUsersScreenCoordinator.swift b/ElementX/Sources/Screens/InviteUsersScreen/InviteUsersScreenCoordinator.swift index bd8df5ad43..c0cb08d8c9 100644 --- a/ElementX/Sources/Screens/InviteUsersScreen/InviteUsersScreenCoordinator.swift +++ b/ElementX/Sources/Screens/InviteUsersScreen/InviteUsersScreenCoordinator.swift @@ -18,11 +18,13 @@ import Combine import SwiftUI struct InviteUsersScreenCoordinatorParameters { - let selectedUsers: CurrentValuePublisher<[UserProfileProxy], Never> - let roomType: InviteUsersScreenRoomType + let clientProxy: ClientProxyProtocol let mediaProvider: MediaProviderProtocol let userDiscoveryService: UserDiscoveryServiceProtocol let userIndicatorController: UserIndicatorControllerProtocol + + let selectedUsers: CurrentValuePublisher<[UserProfileProxy], Never> + let roomType: InviteUsersScreenRoomType } enum InviteUsersScreenCoordinatorAction { @@ -42,11 +44,12 @@ final class InviteUsersScreenCoordinator: CoordinatorProtocol { } init(parameters: InviteUsersScreenCoordinatorParameters) { - viewModel = InviteUsersScreenViewModel(selectedUsers: parameters.selectedUsers, - roomType: parameters.roomType, + viewModel = InviteUsersScreenViewModel(clientProxy: parameters.clientProxy, mediaProvider: parameters.mediaProvider, userDiscoveryService: parameters.userDiscoveryService, - userIndicatorController: parameters.userIndicatorController) + userIndicatorController: parameters.userIndicatorController, + selectedUsers: parameters.selectedUsers, + roomType: parameters.roomType) } func start() { diff --git a/ElementX/Sources/Screens/InviteUsersScreen/InviteUsersScreenViewModel.swift b/ElementX/Sources/Screens/InviteUsersScreen/InviteUsersScreenViewModel.swift index 99d361c214..07793cab1b 100644 --- a/ElementX/Sources/Screens/InviteUsersScreen/InviteUsersScreenViewModel.swift +++ b/ElementX/Sources/Screens/InviteUsersScreen/InviteUsersScreenViewModel.swift @@ -21,28 +21,42 @@ import SwiftUI typealias InviteUsersScreenViewModelType = StateStoreViewModel class InviteUsersScreenViewModel: InviteUsersScreenViewModelType, InviteUsersScreenViewModelProtocol { + private let clientProxy: ClientProxyProtocol private let roomType: InviteUsersScreenRoomType private let userDiscoveryService: UserDiscoveryServiceProtocol private let userIndicatorController: UserIndicatorControllerProtocol - private let actionsSubject: PassthroughSubject = .init() + private var suggestedUsers = [UserProfileProxy]() + private let actionsSubject: PassthroughSubject = .init() var actions: AnyPublisher { actionsSubject.eraseToAnyPublisher() } - init(selectedUsers: CurrentValuePublisher<[UserProfileProxy], Never>, - roomType: InviteUsersScreenRoomType, + init(clientProxy: ClientProxyProtocol, mediaProvider: MediaProviderProtocol, userDiscoveryService: UserDiscoveryServiceProtocol, - userIndicatorController: UserIndicatorControllerProtocol) { - self.roomType = roomType + userIndicatorController: UserIndicatorControllerProtocol, + selectedUsers: CurrentValuePublisher<[UserProfileProxy], Never>, + roomType: InviteUsersScreenRoomType) { + self.clientProxy = clientProxy self.userDiscoveryService = userDiscoveryService self.userIndicatorController = userIndicatorController + + self.roomType = roomType + super.init(initialViewState: InviteUsersScreenViewState(selectedUsers: selectedUsers.value, isCreatingRoom: roomType.isCreatingRoom), imageProvider: mediaProvider) setupSubscriptions(selectedUsers: selectedUsers) fetchMembersIfNeeded() + + Task { + suggestedUsers = await clientProxy.recentConversationCounterparts() + + if state.usersSection.type == .suggestions { + state.usersSection = .init(type: .suggestions, users: suggestedUsers) + } + } } // MARK: - Public @@ -127,29 +141,28 @@ class InviteUsersScreenViewModel: InviteUsersScreenViewModelType, InviteUsersScr private func fetchUsers() { guard searchQuery.count >= 3 else { - state.usersSection = .init(type: .suggestions, users: []) + state.usersSection = .init(type: .suggestions, users: suggestedUsers) return } state.isSearching = true + fetchUsersTask = Task { let result = await userDiscoveryService.searchProfiles(with: searchQuery) + guard !Task.isCancelled else { return } - handleResult(for: .searchResult, result: result) + + state.isSearching = false + + switch result { + case .success(let users): + state.usersSection = .init(type: .searchResult, users: users) + case .failure: + break + } } } - - private func handleResult(for sectionType: UserDiscoverySectionType, result: Result<[UserProfileProxy], UserDiscoveryErrorType>) { - state.isSearching = false - switch result { - case .success(let users): - state.usersSection = .init(type: sectionType, users: users) - case .failure: - break - } - } - private var searchQuery: String { context.searchQuery } diff --git a/ElementX/Sources/Screens/InviteUsersScreen/View/InviteUsersScreen.swift b/ElementX/Sources/Screens/InviteUsersScreen/View/InviteUsersScreen.swift index b69424fdb3..83b144e54a 100644 --- a/ElementX/Sources/Screens/InviteUsersScreen/View/InviteUsersScreen.swift +++ b/ElementX/Sources/Screens/InviteUsersScreen/View/InviteUsersScreen.swift @@ -160,11 +160,12 @@ struct InviteUsersScreen_Previews: PreviewProvider, TestablePreview { static let viewModel = { let userDiscoveryService = UserDiscoveryServiceMock() userDiscoveryService.searchProfilesWithReturnValue = .success([.mockAlice]) - return InviteUsersScreenViewModel(selectedUsers: .init([]), - roomType: .draft, + return InviteUsersScreenViewModel(clientProxy: ClientProxyMock(.init()), mediaProvider: MockMediaProvider(), userDiscoveryService: userDiscoveryService, - userIndicatorController: UserIndicatorControllerMock()) + userIndicatorController: UserIndicatorControllerMock(), + selectedUsers: .init([]), + roomType: .draft) }() static var previews: some View { diff --git a/ElementX/Sources/Screens/StartChatScreen/StartChatScreenCoordinator.swift b/ElementX/Sources/Screens/StartChatScreen/StartChatScreenCoordinator.swift index 8ebfbb9e7d..c353dd20c0 100644 --- a/ElementX/Sources/Screens/StartChatScreen/StartChatScreenCoordinator.swift +++ b/ElementX/Sources/Screens/StartChatScreen/StartChatScreenCoordinator.swift @@ -84,11 +84,12 @@ final class StartChatScreenCoordinator: CoordinatorProtocol { // MARK: - Private private func presentInviteUsersScreen() { - let inviteParameters = InviteUsersScreenCoordinatorParameters(selectedUsers: selectedUsersPublisher, - roomType: .draft, + let inviteParameters = InviteUsersScreenCoordinatorParameters(clientProxy: parameters.userSession.clientProxy, mediaProvider: parameters.userSession.mediaProvider, userDiscoveryService: parameters.userDiscoveryService, - userIndicatorController: parameters.userIndicatorController) + userIndicatorController: parameters.userIndicatorController, + selectedUsers: selectedUsersPublisher, + roomType: .draft) let coordinator = InviteUsersScreenCoordinator(parameters: inviteParameters) coordinator.actions.sink { [weak self] action in guard let self else { return } diff --git a/ElementX/Sources/Screens/StartChatScreen/StartChatScreenViewModel.swift b/ElementX/Sources/Screens/StartChatScreen/StartChatScreenViewModel.swift index ead0e1163a..4558103b9f 100644 --- a/ElementX/Sources/Screens/StartChatScreen/StartChatScreenViewModel.swift +++ b/ElementX/Sources/Screens/StartChatScreen/StartChatScreenViewModel.swift @@ -25,8 +25,9 @@ class StartChatScreenViewModel: StartChatScreenViewModelType, StartChatScreenVie private let userIndicatorController: UserIndicatorControllerProtocol private let userDiscoveryService: UserDiscoveryServiceProtocol - private let actionsSubject: PassthroughSubject = .init() + private var suggestedUsers = [UserProfileProxy]() + private let actionsSubject: PassthroughSubject = .init() var actions: AnyPublisher { actionsSubject.eraseToAnyPublisher() } @@ -43,6 +44,14 @@ class StartChatScreenViewModel: StartChatScreenViewModelType, StartChatScreenVie super.init(initialViewState: StartChatScreenViewState(userID: userSession.userID), imageProvider: userSession.mediaProvider) setupBindings() + + Task { + suggestedUsers = await userSession.clientProxy.recentConversationCounterparts() + + if state.usersSection.type == .suggestions { + state.usersSection = .init(type: .suggestions, users: suggestedUsers) + } + } } // MARK: - Public @@ -102,22 +111,21 @@ class StartChatScreenViewModel: StartChatScreenViewModelType, StartChatScreenVie private func fetchUsers() { guard searchQuery.count >= 3 else { - state.usersSection = .init(type: .suggestions, users: []) + state.usersSection = .init(type: .suggestions, users: suggestedUsers) return } + fetchUsersTask = Task { let result = await userDiscoveryService.searchProfiles(with: searchQuery) + guard !Task.isCancelled else { return } - handleResult(for: .searchResult, result: result) - } - } - - private func handleResult(for sectionType: UserDiscoverySectionType, result: Result<[UserProfileProxy], UserDiscoveryErrorType>) { - switch result { - case .success(let users): - state.usersSection = .init(type: sectionType, users: users) - case .failure: - break + + switch result { + case .success(let users): + state.usersSection = .init(type: .searchResult, users: users) + case .failure: + break + } } } diff --git a/ElementX/Sources/Services/Client/ClientProxy.swift b/ElementX/Sources/Services/Client/ClientProxy.swift index 40c0e614cf..ec54a29fd8 100644 --- a/ElementX/Sources/Services/Client/ClientProxy.swift +++ b/ElementX/Sources/Services/Client/ClientProxy.swift @@ -555,7 +555,7 @@ class ClientProxy: ClientProxyProtocol { RoomDirectorySearchProxy(roomDirectorySearch: client.roomDirectorySearch()) } - // MARK: - Ignored users + // MARK: Ignored users func ignoreUser(_ userID: String) async -> Result { do { @@ -577,7 +577,58 @@ class ClientProxy: ClientProxyProtocol { } } - // MARK: Private + // MARK: Recently visited rooms + + func trackRecentlyVisitedRoom(_ roomID: String) async -> Result { + do { + try await client.trackRecentlyVisitedRoom(room: roomID) + return .success(()) + } catch { + MXLog.error("Failed tracking recently visited room: \(roomID) with error: \(error)") + return .failure(.generic(error)) + } + } + + func recentlyVisitedRooms() async -> Result<[String], ClientProxyError> { + do { + let result = try await client.getRecentlyVisitedRooms() + return .success(result) + } catch { + MXLog.error("Failed retrieving recently visited rooms with error: \(error)") + return .failure(.generic(error)) + } + } + + func recentConversationCounterparts() async -> [UserProfileProxy] { + let maxResultsToReturn = 5 + + guard case let .success(roomIdentifiers) = await recentlyVisitedRooms() else { + return [] + } + + var users = [UserProfileProxy]() + + for roomID in roomIdentifiers { + guard let room = await roomForIdentifier(roomID), + room.isDirect, + let members = await room.members() else { + continue + } + + for member in members where member.isActive && member.userID != userID { + users.append(.init(userID: member.userID, displayName: member.displayName, avatarURL: member.avatarURL)) + + // Return early to avoid unnecessary work + if users.count >= maxResultsToReturn { + return users + } + } + } + + return users + } + + // MARK: - Private private func loadUserAvatarURLFromCache() { loadCachedAvatarURLTask = Task { diff --git a/ElementX/Sources/Services/Client/ClientProxyProtocol.swift b/ElementX/Sources/Services/Client/ClientProxyProtocol.swift index 7b40b9cc38..63139c88ac 100644 --- a/ElementX/Sources/Services/Client/ClientProxyProtocol.swift +++ b/ElementX/Sources/Services/Client/ClientProxyProtocol.swift @@ -38,6 +38,7 @@ enum ClientProxyLoadingState { } enum ClientProxyError: Error { + case generic(Error?) case failedCreatingRoom case failedRetrievingDirectRoom case failedRetrievingUserDisplayName @@ -160,4 +161,12 @@ protocol ClientProxyProtocol: AnyObject, MediaLoaderProtocol { func ignoreUser(_ userID: String) async -> Result func unignoreUser(_ userID: String) async -> Result + + // MARK: - Recently visited rooms + + func trackRecentlyVisitedRoom(_ roomID: String) async -> Result + + func recentlyVisitedRooms() async -> Result<[String], ClientProxyError> + + func recentConversationCounterparts() async -> [UserProfileProxy] } diff --git a/UnitTests/Sources/InviteUsersViewModelTests.swift b/UnitTests/Sources/InviteUsersViewModelTests.swift index 26cc85880c..eb65431cc8 100644 --- a/UnitTests/Sources/InviteUsersViewModelTests.swift +++ b/UnitTests/Sources/InviteUsersViewModelTests.swift @@ -98,10 +98,12 @@ class InviteUsersScreenViewModelTests: XCTestCase { userDiscoveryService = UserDiscoveryServiceMock() userDiscoveryService.searchProfilesWithReturnValue = .success([]) usersSubject.send([]) - let viewModel = InviteUsersScreenViewModel(selectedUsers: usersSubject.asCurrentValuePublisher(), - roomType: roomType, mediaProvider: MockMediaProvider(), + let viewModel = InviteUsersScreenViewModel(clientProxy: ClientProxyMock(.init()), + mediaProvider: MockMediaProvider(), userDiscoveryService: userDiscoveryService, - userIndicatorController: UserIndicatorControllerMock()) + userIndicatorController: UserIndicatorControllerMock(), + selectedUsers: usersSubject.asCurrentValuePublisher(), + roomType: roomType) viewModel.state.usersSection = .init(type: .suggestions, users: [.mockAlice, .mockBob, .mockCharlie]) self.viewModel = viewModel diff --git a/UnitTests/Sources/LoggingTests.swift b/UnitTests/Sources/LoggingTests.swift index 32f3a8a202..5117991c46 100644 --- a/UnitTests/Sources/LoggingTests.swift +++ b/UnitTests/Sources/LoggingTests.swift @@ -222,10 +222,9 @@ class LoggingTests: XCTestCase { let rustEmoteMessage = EmoteMessageContent(body: emoteString, formatted: FormattedBody(format: .html, body: "\(emoteString)")) - let pointer = Unmanaged.passRetained(NSURL(fileURLWithPath: "/tmp/file")).toOpaque() - let rustImageMessage = ImageMessageContent(body: "ImageString", formatted: nil, filename: nil, source: MediaSource(unsafeFromRawPointer: pointer), info: nil) - let rustVideoMessage = VideoMessageContent(body: "VideoString", formatted: nil, filename: nil, source: MediaSource(unsafeFromRawPointer: pointer), info: nil) - let rustFileMessage = FileMessageContent(body: "FileString", formatted: nil, filename: "FileName", source: MediaSource(unsafeFromRawPointer: pointer), info: nil) + let rustImageMessage = ImageMessageContent(body: "ImageString", formatted: nil, filename: nil, source: MediaSource(noPointer: .init()), info: nil) + let rustVideoMessage = VideoMessageContent(body: "VideoString", formatted: nil, filename: nil, source: MediaSource(noPointer: .init()), info: nil) + let rustFileMessage = FileMessageContent(body: "FileString", formatted: nil, filename: "FileName", source: MediaSource(noPointer: .init()), info: nil) // When logging that value MXLog.info(rustTextMessage)