diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index 1c29824e7..adc90144b 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -5008,7 +5008,7 @@ repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift"; requirement = { kind = exactVersion; - version = "1.0.78-alpha"; + version = "1.0.79-alpha"; }; }; 96495DD8554E2F39D3954354 /* XCRemoteSwiftPackageReference "posthog-ios" */ = { diff --git a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 319b25cee..9ca71ed95 100644 --- a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -11,7 +11,7 @@ { "identity" : "compound-ios", "kind" : "remoteSourceControl", - "location" : "https://github.com/vector-im/compound-ios.git", + "location" : "https://github.com/vector-im/compound-ios", "state" : { "revision" : "e8b35fdd8c4008079dfce203e63bf7a05582d7b9" } @@ -111,8 +111,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/matrix-org/matrix-rust-components-swift", "state" : { - "revision" : "278e5694266e6b88b675d39a68391025b3b72bcb", - "version" : "1.0.78-alpha" + "revision" : "59c10bfd0b2dee9b5bf41b536ffac472d4fc49db", + "version" : "1.0.79-alpha" } }, { @@ -181,7 +181,7 @@ { "identity" : "swift-snapshot-testing", "kind" : "remoteSourceControl", - "location" : "https://github.com/pointfreeco/swift-snapshot-testing", + "location" : "https://github.com/pointfreeco/swift-snapshot-testing.git", "state" : { "revision" : "cef5b3f6f11781dd4591bdd1dd0a3d22bd609334", "version" : "1.11.0" diff --git a/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift b/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift index 1cd94d178..f354ef895 100644 --- a/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift +++ b/ElementX/Sources/Mocks/Generated/SDKGeneratedMocks.swift @@ -652,27 +652,27 @@ class SDKClientMock: SDKClientProtocol { } //MARK: - `uploadMedia` - public var uploadMediaMimeTypeDataThrowableError: Error? - public var uploadMediaMimeTypeDataCallsCount = 0 - public var uploadMediaMimeTypeDataCalled: Bool { - return uploadMediaMimeTypeDataCallsCount > 0 + public var uploadMediaMimeTypeDataProgressWatcherThrowableError: Error? + public var uploadMediaMimeTypeDataProgressWatcherCallsCount = 0 + public var uploadMediaMimeTypeDataProgressWatcherCalled: Bool { + return uploadMediaMimeTypeDataProgressWatcherCallsCount > 0 } - public var uploadMediaMimeTypeDataReceivedArguments: (`mimeType`: String, `data`: [UInt8])? - public var uploadMediaMimeTypeDataReceivedInvocations: [(`mimeType`: String, `data`: [UInt8])] = [] - public var uploadMediaMimeTypeDataReturnValue: String! - public var uploadMediaMimeTypeDataClosure: ((String, [UInt8]) throws -> String)? + public var uploadMediaMimeTypeDataProgressWatcherReceivedArguments: (`mimeType`: String, `data`: [UInt8], `progressWatcher`: ProgressWatcher?)? + public var uploadMediaMimeTypeDataProgressWatcherReceivedInvocations: [(`mimeType`: String, `data`: [UInt8], `progressWatcher`: ProgressWatcher?)] = [] + public var uploadMediaMimeTypeDataProgressWatcherReturnValue: String! + public var uploadMediaMimeTypeDataProgressWatcherClosure: ((String, [UInt8], ProgressWatcher?) throws -> String)? - public func `uploadMedia`(`mimeType`: String, `data`: [UInt8]) throws -> String { - if let error = uploadMediaMimeTypeDataThrowableError { + public func `uploadMedia`(`mimeType`: String, `data`: [UInt8], `progressWatcher`: ProgressWatcher?) throws -> String { + if let error = uploadMediaMimeTypeDataProgressWatcherThrowableError { throw error } - uploadMediaMimeTypeDataCallsCount += 1 - uploadMediaMimeTypeDataReceivedArguments = (mimeType: mimeType, data: data) - uploadMediaMimeTypeDataReceivedInvocations.append((mimeType: mimeType, data: data)) - if let uploadMediaMimeTypeDataClosure = uploadMediaMimeTypeDataClosure { - return try uploadMediaMimeTypeDataClosure(`mimeType`, `data`) + uploadMediaMimeTypeDataProgressWatcherCallsCount += 1 + uploadMediaMimeTypeDataProgressWatcherReceivedArguments = (mimeType: mimeType, data: data, progressWatcher: progressWatcher) + uploadMediaMimeTypeDataProgressWatcherReceivedInvocations.append((mimeType: mimeType, data: data, progressWatcher: progressWatcher)) + if let uploadMediaMimeTypeDataProgressWatcherClosure = uploadMediaMimeTypeDataProgressWatcherClosure { + return try uploadMediaMimeTypeDataProgressWatcherClosure(`mimeType`, `data`, `progressWatcher`) } else { - return uploadMediaMimeTypeDataReturnValue + return uploadMediaMimeTypeDataProgressWatcherReturnValue } } //MARK: - `userId` diff --git a/ElementX/Sources/Services/Client/ClientProxy.swift b/ElementX/Sources/Services/Client/ClientProxy.swift index 904a4e0f5..d0a81951b 100644 --- a/ElementX/Sources/Services/Client/ClientProxy.swift +++ b/ElementX/Sources/Services/Client/ClientProxy.swift @@ -47,7 +47,6 @@ class ClientProxy: ClientProxyProtocol { private let clientQueue: DispatchQueue private var roomListService: RoomList? - private var roomListSyncTaskHandle: TaskHandle? private var roomListStateUpdateTaskHandle: TaskHandle? var roomSummaryProvider: RoomSummaryProviderProtocol? @@ -71,7 +70,7 @@ class ClientProxy: ClientProxyProtocol { // These need to be inlined instead of using stopSync() // as we can't call async methods safely from deinit client.setDelegate(delegate: nil) - roomListSyncTaskHandle?.cancel() + try? roomListService?.stopSync() } let callbacks = PassthroughSubject() @@ -123,7 +122,7 @@ class ClientProxy: ClientProxyProtocol { } var isSyncing: Bool { - roomListSyncTaskHandle != nil + roomListService?.isSyncing() ?? false } func startSync() { @@ -132,13 +131,16 @@ class ClientProxy: ClientProxyProtocol { return } - roomListSyncTaskHandle = roomListService?.sync() + roomListService?.sync() } - + func stopSync() { MXLog.info("Stopping sync") - roomListSyncTaskHandle?.cancel() - roomListSyncTaskHandle = nil + do { + try roomListService?.stopSync() + } catch { + MXLog.error("Failed stopping room list service with error: \(error)") + } } func directRoomForUserID(_ userID: String) async -> Result { @@ -192,7 +194,7 @@ class ClientProxy: ClientProxyProtocol { return await Task.dispatch(on: clientQueue) { do { let data = try Data(contentsOf: media.url) - let matrixUrl = try self.client.uploadMedia(mimeType: mimeType, data: [UInt8](data)) + let matrixUrl = try self.client.uploadMedia(mimeType: mimeType, data: [UInt8](data), progressWatcher: nil) return .success(matrixUrl) } catch let error as ClientError { return .failure(ClientProxyError.failedUploadingMedia(error.code)) @@ -388,16 +390,14 @@ class ClientProxy: ClientProxyProtocol { guard let self else { return } MXLog.info("Received room list update: \(state)") - if state == .allRooms || state == .carryOn { - self.callbacks.send(.receivedSyncUpdate) - } - - #warning("Not great, not terrible (ツ)") + // Restart the room list sync on every error for now if state == .terminated { self.restartSync() } - if state == .allRooms { + if state == .running { + self.callbacks.send(.receivedSyncUpdate) + Task { // Subscribe to invites later as the underlying SlidingSync list is only added when entering AllRooms await self.inviteSummaryProvider?.subscribeIfNecessary(entriesFunction: roomListService.invites(listener:), diff --git a/ElementX/Sources/Services/Notification/Proxy/NotificationItemProxy.swift b/ElementX/Sources/Services/Notification/Proxy/NotificationItemProxy.swift index 6bebdd198..7bf994fa3 100644 --- a/ElementX/Sources/Services/Notification/Proxy/NotificationItemProxy.swift +++ b/ElementX/Sources/Services/Notification/Proxy/NotificationItemProxy.swift @@ -283,6 +283,8 @@ extension NotificationItemProxyProtocol { return try await processNotice(content: content, mediaProvider: mediaProvider) case .text(content: let content): return try await processText(content: content, mediaProvider: mediaProvider) + case .location: + return processEmpty() } } diff --git a/ElementX/Sources/Services/Room/RoomProxy.swift b/ElementX/Sources/Services/Room/RoomProxy.swift index d8455bacf..672b8322c 100644 --- a/ElementX/Sources/Services/Room/RoomProxy.swift +++ b/ElementX/Sources/Services/Room/RoomProxy.swift @@ -284,7 +284,7 @@ class RoomProxy: RoomProxyProtocol { return await Task.dispatch(on: userInitiatedDispatchQueue) { do { - try self.room.sendImage(url: url.path(), thumbnailUrl: thumbnailURL.path(), imageInfo: imageInfo) + try self.room.sendImage(url: url.path(), thumbnailUrl: thumbnailURL.path(), imageInfo: imageInfo, progressWatcher: nil) return .success(()) } catch { return .failure(.failedSendingMedia) @@ -300,7 +300,7 @@ class RoomProxy: RoomProxyProtocol { return await Task.dispatch(on: userInitiatedDispatchQueue) { do { - try self.room.sendVideo(url: url.path(), thumbnailUrl: thumbnailURL.path(), videoInfo: videoInfo) + try self.room.sendVideo(url: url.path(), thumbnailUrl: thumbnailURL.path(), videoInfo: videoInfo, progressWatcher: nil) return .success(()) } catch { return .failure(.failedSendingMedia) @@ -316,7 +316,7 @@ class RoomProxy: RoomProxyProtocol { return await Task.dispatch(on: userInitiatedDispatchQueue) { do { - try self.room.sendAudio(url: url.path(), audioInfo: audioInfo) + try self.room.sendAudio(url: url.path(), audioInfo: audioInfo, progressWatcher: nil) return .success(()) } catch { return .failure(.failedSendingMedia) @@ -332,7 +332,7 @@ class RoomProxy: RoomProxyProtocol { return await Task.dispatch(on: userInitiatedDispatchQueue) { do { - try self.room.sendFile(url: url.path(), fileInfo: fileInfo) + try self.room.sendFile(url: url.path(), fileInfo: fileInfo, progressWatcher: nil) return .success(()) } catch { return .failure(.failedSendingMedia) diff --git a/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactory.swift b/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactory.swift index 17b016155..48b629f5b 100644 --- a/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactory.swift +++ b/ElementX/Sources/Services/Timeline/TimelineItems/RoomTimelineItemFactory.swift @@ -74,6 +74,8 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol { return buildEmoteTimelineItem(for: eventItemProxy, messageTimelineItem, content, isOutgoing) case .audio(let content): return buildAudioTimelineItem(for: eventItemProxy, messageTimelineItem, content, isOutgoing) + case .location: + return nil case .none: return nil } @@ -488,6 +490,8 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol { replyContent = .text(buildTextTimelineItemContent(content)) case .video(let content): replyContent = .video(buildVideoTimelineItemContent(content)) + case .location: + return nil case .none: return nil } diff --git a/project.yml b/project.yml index 7639528d0..cb22e721b 100644 --- a/project.yml +++ b/project.yml @@ -44,7 +44,7 @@ include: packages: MatrixRustSDK: url: https://github.com/matrix-org/matrix-rust-components-swift - exactVersion: 1.0.78-alpha + exactVersion: 1.0.79-alpha # path: ../matrix-rust-sdk DesignKit: path: DesignKit