diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index 5b5ada4e1..cca0f46a7 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -5038,7 +5038,7 @@ repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift"; requirement = { kind = exactVersion; - version = "1.0.82-alpha"; + version = "1.0.84-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 b312bf32c..07f9725db 100644 --- a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -111,8 +111,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/matrix-org/matrix-rust-components-swift", "state" : { - "revision" : "fbac557ed23d326f4838f2cd4a902c6b54851311", - "version" : "1.0.82-alpha" + "revision" : "ff4185d36530b4368f45ddee69f9cfb99ab336d0", + "version" : "1.0.84-alpha" } }, { diff --git a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift index 2717f06d9..ec2f43cd7 100644 --- a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift +++ b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift @@ -715,6 +715,27 @@ class RoomProxyMock: RoomProxyProtocol { return sendFileUrlFileInfoProgressSubjectReturnValue } } + //MARK: - sendLocation + + var sendLocationBodyGeoURICallsCount = 0 + var sendLocationBodyGeoURICalled: Bool { + return sendLocationBodyGeoURICallsCount > 0 + } + var sendLocationBodyGeoURIReceivedArguments: (body: String, geoURI: GeoURI)? + var sendLocationBodyGeoURIReceivedInvocations: [(body: String, geoURI: GeoURI)] = [] + var sendLocationBodyGeoURIReturnValue: Result! + var sendLocationBodyGeoURIClosure: ((String, GeoURI) async -> Result)? + + func sendLocation(body: String, geoURI: GeoURI) async -> Result { + sendLocationBodyGeoURICallsCount += 1 + sendLocationBodyGeoURIReceivedArguments = (body: body, geoURI: geoURI) + sendLocationBodyGeoURIReceivedInvocations.append((body: body, geoURI: geoURI)) + if let sendLocationBodyGeoURIClosure = sendLocationBodyGeoURIClosure { + return await sendLocationBodyGeoURIClosure(body, geoURI) + } else { + return sendLocationBodyGeoURIReturnValue + } + } //MARK: - retrySend var retrySendTransactionIDCallsCount = 0 diff --git a/ElementX/Sources/Screens/RoomScreen/View/Supplementary/TimelineItemStatusView.swift b/ElementX/Sources/Screens/RoomScreen/View/Supplementary/TimelineItemStatusView.swift index 4d9d08483..ff542bbcc 100644 --- a/ElementX/Sources/Screens/RoomScreen/View/Supplementary/TimelineItemStatusView.swift +++ b/ElementX/Sources/Screens/RoomScreen/View/Supplementary/TimelineItemStatusView.swift @@ -64,6 +64,7 @@ struct TimelineItemStatusView: View { TimelineDeliveryStatusView(deliveryStatus: .sent) } case .sendingFailed: + // The bubbles handle the failure internally if style == .plain { Image(systemName: "exclamationmark.circle.fill") .resizable() @@ -73,7 +74,8 @@ struct TimelineItemStatusView: View { context.sendFailedConfirmationDialogInfo = .init(transactionID: timelineItem.properties.transactionID) } } - // The bubbles handle the failure internally + case .cancelled: + EmptyView() } } diff --git a/ElementX/Sources/Services/Room/RoomProxy.swift b/ElementX/Sources/Services/Room/RoomProxy.swift index e2cc3de52..84a2db125 100644 --- a/ElementX/Sources/Services/Room/RoomProxy.swift +++ b/ElementX/Sources/Services/Room/RoomProxy.swift @@ -348,6 +348,19 @@ class RoomProxy: RoomProxyProtocol { } } + func sendLocation(body: String, geoURI: GeoURI) async -> Result { + sendMessageBackgroundTask = backgroundTaskService.startBackgroundTask(withName: backgroundTaskName, isReusable: true) + defer { + sendMessageBackgroundTask?.stop() + } + + let transactionId = genTransactionId() + + return await Task.dispatch(on: userInitiatedDispatchQueue) { + .success(self.room.sendLocation(body: body, geoUri: geoURI.string, txnId: transactionId)) + } + } + func retrySend(transactionID: String) async { sendMessageBackgroundTask = backgroundTaskService.startBackgroundTask(withName: backgroundTaskName, isReusable: true) defer { diff --git a/ElementX/Sources/Services/Room/RoomProxyProtocol.swift b/ElementX/Sources/Services/Room/RoomProxyProtocol.swift index cc5566692..8c08c906e 100644 --- a/ElementX/Sources/Services/Room/RoomProxyProtocol.swift +++ b/ElementX/Sources/Services/Room/RoomProxyProtocol.swift @@ -41,6 +41,7 @@ enum RoomProxyError: Error { case failedSettingRoomTopic case failedRemovingAvatar case failedUploadingAvatar + case failedSendingLocation } @MainActor @@ -101,6 +102,8 @@ protocol RoomProxyProtocol { func sendFile(url: URL, fileInfo: FileInfo, progressSubject: CurrentValueSubject?) async -> Result + func sendLocation(body: String, geoURI: GeoURI) async -> Result + /// Retries sending a failed message given its transaction ID func retrySend(transactionID: String) async diff --git a/ElementX/Sources/Services/Timeline/TimelineItemProxy.swift b/ElementX/Sources/Services/Timeline/TimelineItemProxy.swift index 5b800c8fa..aee9fa4be 100644 --- a/ElementX/Sources/Services/Timeline/TimelineItemProxy.swift +++ b/ElementX/Sources/Services/Timeline/TimelineItemProxy.swift @@ -39,6 +39,7 @@ enum TimelineItemDeliveryStatus: Hashable { case sending case sent case sendingFailed + case cancelled } /// A light wrapper around event timeline items returned from Rust. @@ -69,6 +70,8 @@ struct EventTimelineItemProxy { return .sendingFailed case .sent: return .sent + case .cancelled: + return .cancelled } } diff --git a/project.yml b/project.yml index 8379009c2..f9a9fc01e 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.82-alpha + exactVersion: 1.0.84-alpha # path: ../matrix-rust-sdk DesignKit: path: DesignKit