Update Matrix SDK to v1.0.84-alpha (#1147)

* Fix build errors

* Add sendLocation API

* Amend cancelled behavior
This commit is contained in:
Alfonso Grillo
2023-06-23 17:14:38 +02:00
committed by GitHub
parent 9c115d8e25
commit 1f99e9af8d
8 changed files with 47 additions and 5 deletions
+1 -1
View File
@@ -5038,7 +5038,7 @@
repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift"; repositoryURL = "https://github.com/matrix-org/matrix-rust-components-swift";
requirement = { requirement = {
kind = exactVersion; kind = exactVersion;
version = "1.0.82-alpha"; version = "1.0.84-alpha";
}; };
}; };
96495DD8554E2F39D3954354 /* XCRemoteSwiftPackageReference "posthog-ios" */ = { 96495DD8554E2F39D3954354 /* XCRemoteSwiftPackageReference "posthog-ios" */ = {
@@ -111,8 +111,8 @@
"kind" : "remoteSourceControl", "kind" : "remoteSourceControl",
"location" : "https://github.com/matrix-org/matrix-rust-components-swift", "location" : "https://github.com/matrix-org/matrix-rust-components-swift",
"state" : { "state" : {
"revision" : "fbac557ed23d326f4838f2cd4a902c6b54851311", "revision" : "ff4185d36530b4368f45ddee69f9cfb99ab336d0",
"version" : "1.0.82-alpha" "version" : "1.0.84-alpha"
} }
}, },
{ {
@@ -715,6 +715,27 @@ class RoomProxyMock: RoomProxyProtocol {
return sendFileUrlFileInfoProgressSubjectReturnValue 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<Void, RoomProxyError>!
var sendLocationBodyGeoURIClosure: ((String, GeoURI) async -> Result<Void, RoomProxyError>)?
func sendLocation(body: String, geoURI: GeoURI) async -> Result<Void, RoomProxyError> {
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 //MARK: - retrySend
var retrySendTransactionIDCallsCount = 0 var retrySendTransactionIDCallsCount = 0
@@ -64,6 +64,7 @@ struct TimelineItemStatusView: View {
TimelineDeliveryStatusView(deliveryStatus: .sent) TimelineDeliveryStatusView(deliveryStatus: .sent)
} }
case .sendingFailed: case .sendingFailed:
// The bubbles handle the failure internally
if style == .plain { if style == .plain {
Image(systemName: "exclamationmark.circle.fill") Image(systemName: "exclamationmark.circle.fill")
.resizable() .resizable()
@@ -73,7 +74,8 @@ struct TimelineItemStatusView: View {
context.sendFailedConfirmationDialogInfo = .init(transactionID: timelineItem.properties.transactionID) context.sendFailedConfirmationDialogInfo = .init(transactionID: timelineItem.properties.transactionID)
} }
} }
// The bubbles handle the failure internally case .cancelled:
EmptyView()
} }
} }
@@ -348,6 +348,19 @@ class RoomProxy: RoomProxyProtocol {
} }
} }
func sendLocation(body: String, geoURI: GeoURI) async -> Result<Void, RoomProxyError> {
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 { func retrySend(transactionID: String) async {
sendMessageBackgroundTask = backgroundTaskService.startBackgroundTask(withName: backgroundTaskName, isReusable: true) sendMessageBackgroundTask = backgroundTaskService.startBackgroundTask(withName: backgroundTaskName, isReusable: true)
defer { defer {
@@ -41,6 +41,7 @@ enum RoomProxyError: Error {
case failedSettingRoomTopic case failedSettingRoomTopic
case failedRemovingAvatar case failedRemovingAvatar
case failedUploadingAvatar case failedUploadingAvatar
case failedSendingLocation
} }
@MainActor @MainActor
@@ -101,6 +102,8 @@ protocol RoomProxyProtocol {
func sendFile(url: URL, fileInfo: FileInfo, progressSubject: CurrentValueSubject<Double, Never>?) async -> Result<Void, RoomProxyError> func sendFile(url: URL, fileInfo: FileInfo, progressSubject: CurrentValueSubject<Double, Never>?) async -> Result<Void, RoomProxyError>
func sendLocation(body: String, geoURI: GeoURI) async -> Result<Void, RoomProxyError>
/// Retries sending a failed message given its transaction ID /// Retries sending a failed message given its transaction ID
func retrySend(transactionID: String) async func retrySend(transactionID: String) async
@@ -39,6 +39,7 @@ enum TimelineItemDeliveryStatus: Hashable {
case sending case sending
case sent case sent
case sendingFailed case sendingFailed
case cancelled
} }
/// A light wrapper around event timeline items returned from Rust. /// A light wrapper around event timeline items returned from Rust.
@@ -69,6 +70,8 @@ struct EventTimelineItemProxy {
return .sendingFailed return .sendingFailed
case .sent: case .sent:
return .sent return .sent
case .cancelled:
return .cancelled
} }
} }
+1 -1
View File
@@ -44,7 +44,7 @@ include:
packages: packages:
MatrixRustSDK: MatrixRustSDK:
url: https://github.com/matrix-org/matrix-rust-components-swift url: https://github.com/matrix-org/matrix-rust-components-swift
exactVersion: 1.0.82-alpha exactVersion: 1.0.84-alpha
# path: ../matrix-rust-sdk # path: ../matrix-rust-sdk
DesignKit: DesignKit:
path: DesignKit path: DesignKit