Update SDK to 1.0.94-alpha (#1232)

* Update SDK

* Map new location fields

* Add LocationRoomTimelineItemContent.AssetType
This commit is contained in:
Alfonso Grillo
2023-07-04 08:39:32 +02:00
committed by GitHub
parent 4162036f83
commit caf23094b0
16 changed files with 89 additions and 36 deletions
+1 -1
View File
@@ -5147,7 +5147,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.93-alpha"; version = "1.0.94-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" : "40645a27fd55bbe0fa2065a90496fc823f45ff6e", "revision" : "6d6c13bcf3bf900932599a62e2a157224d762630",
"version" : "1.0.93-alpha" "version" : "1.0.94-alpha"
} }
}, },
{ {
@@ -308,8 +308,8 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
stateMachine.tryEvent(.presentEmojiPicker(itemID: itemID)) stateMachine.tryEvent(.presentEmojiPicker(itemID: itemID))
case .presentLocationPicker: case .presentLocationPicker:
stateMachine.tryEvent(.presentMapNavigator(interactionMode: .picker)) stateMachine.tryEvent(.presentMapNavigator(interactionMode: .picker))
case .presentLocationViewer(_, let geoURI): case .presentLocationViewer(_, let geoURI, let description):
stateMachine.tryEvent(.presentMapNavigator(interactionMode: .viewOnly(geoURI: geoURI))) stateMachine.tryEvent(.presentMapNavigator(interactionMode: .viewOnly(geoURI: geoURI, description: description)))
case .presentRoomMemberDetails(member: let member): case .presentRoomMemberDetails(member: let member):
stateMachine.tryEvent(.presentRoomMemberDetails(member: .init(value: member))) stateMachine.tryEvent(.presentRoomMemberDetails(member: .init(value: member)))
case .presentMessageForwarding(let itemID): case .presentMessageForwarding(let itemID):
@@ -513,7 +513,11 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
switch action { switch action {
case .selectedLocation(let geoURI): case .selectedLocation(let geoURI):
Task { Task {
_ = await self.roomProxy?.sendLocation(body: geoURI.bodyMessage, geoURI: geoURI) _ = await self.roomProxy?.sendLocation(body: geoURI.bodyMessage,
geoURI: geoURI,
description: nil,
zoomLevel: nil,
assetType: .pin)
self.navigationSplitCoordinator.setSheetCoordinator(nil) self.navigationSplitCoordinator.setSheetCoordinator(nil)
} }
case .close: case .close:
@@ -705,23 +705,23 @@ class RoomProxyMock: RoomProxyProtocol {
} }
//MARK: - sendLocation //MARK: - sendLocation
var sendLocationBodyGeoURICallsCount = 0 var sendLocationBodyGeoURIDescriptionZoomLevelAssetTypeCallsCount = 0
var sendLocationBodyGeoURICalled: Bool { var sendLocationBodyGeoURIDescriptionZoomLevelAssetTypeCalled: Bool {
return sendLocationBodyGeoURICallsCount > 0 return sendLocationBodyGeoURIDescriptionZoomLevelAssetTypeCallsCount > 0
} }
var sendLocationBodyGeoURIReceivedArguments: (body: String, geoURI: GeoURI)? var sendLocationBodyGeoURIDescriptionZoomLevelAssetTypeReceivedArguments: (body: String, geoURI: GeoURI, description: String?, zoomLevel: UInt8?, assetType: AssetType?)?
var sendLocationBodyGeoURIReceivedInvocations: [(body: String, geoURI: GeoURI)] = [] var sendLocationBodyGeoURIDescriptionZoomLevelAssetTypeReceivedInvocations: [(body: String, geoURI: GeoURI, description: String?, zoomLevel: UInt8?, assetType: AssetType?)] = []
var sendLocationBodyGeoURIReturnValue: Result<Void, RoomProxyError>! var sendLocationBodyGeoURIDescriptionZoomLevelAssetTypeReturnValue: Result<Void, RoomProxyError>!
var sendLocationBodyGeoURIClosure: ((String, GeoURI) async -> Result<Void, RoomProxyError>)? var sendLocationBodyGeoURIDescriptionZoomLevelAssetTypeClosure: ((String, GeoURI, String?, UInt8?, AssetType?) async -> Result<Void, RoomProxyError>)?
func sendLocation(body: String, geoURI: GeoURI) async -> Result<Void, RoomProxyError> { func sendLocation(body: String, geoURI: GeoURI, description: String?, zoomLevel: UInt8?, assetType: AssetType?) async -> Result<Void, RoomProxyError> {
sendLocationBodyGeoURICallsCount += 1 sendLocationBodyGeoURIDescriptionZoomLevelAssetTypeCallsCount += 1
sendLocationBodyGeoURIReceivedArguments = (body: body, geoURI: geoURI) sendLocationBodyGeoURIDescriptionZoomLevelAssetTypeReceivedArguments = (body: body, geoURI: geoURI, description: description, zoomLevel: zoomLevel, assetType: assetType)
sendLocationBodyGeoURIReceivedInvocations.append((body: body, geoURI: geoURI)) sendLocationBodyGeoURIDescriptionZoomLevelAssetTypeReceivedInvocations.append((body: body, geoURI: geoURI, description: description, zoomLevel: zoomLevel, assetType: assetType))
if let sendLocationBodyGeoURIClosure = sendLocationBodyGeoURIClosure { if let sendLocationBodyGeoURIDescriptionZoomLevelAssetTypeClosure = sendLocationBodyGeoURIDescriptionZoomLevelAssetTypeClosure {
return await sendLocationBodyGeoURIClosure(body, geoURI) return await sendLocationBodyGeoURIDescriptionZoomLevelAssetTypeClosure(body, geoURI, description, zoomLevel, assetType)
} else { } else {
return sendLocationBodyGeoURIReturnValue return sendLocationBodyGeoURIDescriptionZoomLevelAssetTypeReturnValue
} }
} }
//MARK: - retrySend //MARK: - retrySend
@@ -30,7 +30,7 @@ enum RoomScreenCoordinatorAction {
case presentMediaUploadPreviewScreen(URL) case presentMediaUploadPreviewScreen(URL)
case presentRoomDetails case presentRoomDetails
case presentLocationPicker case presentLocationPicker
case presentLocationViewer(body: String, geoURI: GeoURI) case presentLocationViewer(body: String, geoURI: GeoURI, description: String?)
case presentEmojiPicker(itemID: String) case presentEmojiPicker(itemID: String)
case presentRoomMemberDetails(member: RoomMemberProxyProtocol) case presentRoomMemberDetails(member: RoomMemberProxyProtocol)
case presentMessageForwarding(itemID: String) case presentMessageForwarding(itemID: String)
@@ -85,8 +85,8 @@ final class RoomScreenCoordinator: CoordinatorProtocol {
actionsSubject.send(.presentRoomMemberDetails(member: member)) actionsSubject.send(.presentRoomMemberDetails(member: member))
case .displayMessageForwarding(let itemID): case .displayMessageForwarding(let itemID):
actionsSubject.send(.presentMessageForwarding(itemID: itemID)) actionsSubject.send(.presentMessageForwarding(itemID: itemID))
case .displayLocation(let body, let geoURI): case .displayLocation(let body, let geoURI, let description):
actionsSubject.send(.presentLocationViewer(body: body, geoURI: geoURI)) actionsSubject.send(.presentLocationViewer(body: body, geoURI: geoURI, description: description))
} }
} }
} }
@@ -29,7 +29,7 @@ enum RoomScreenViewModelAction {
case displayMediaUploadPreviewScreen(url: URL) case displayMediaUploadPreviewScreen(url: URL)
case displayRoomMemberDetails(member: RoomMemberProxyProtocol) case displayRoomMemberDetails(member: RoomMemberProxyProtocol)
case displayMessageForwarding(itemID: String) case displayMessageForwarding(itemID: String)
case displayLocation(body: String, geoURI: GeoURI) case displayLocation(body: String, geoURI: GeoURI, description: String?)
} }
enum RoomScreenComposerMode: Equatable { enum RoomScreenComposerMode: Equatable {
@@ -223,8 +223,8 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
switch action { switch action {
case .displayMediaFile(let file, let title): case .displayMediaFile(let file, let title):
state.bindings.mediaPreviewItem = MediaPreviewItem(file: file, title: title) state.bindings.mediaPreviewItem = MediaPreviewItem(file: file, title: title)
case .displayLocation(let body, let geoURI): case .displayLocation(let body, let geoURI, let description):
callback?(.displayLocation(body: body, geoURI: geoURI)) callback?(.displayLocation(body: body, geoURI: geoURI, description: description))
case .none: case .none:
break break
} }
@@ -229,7 +229,7 @@ struct TimelineReplyView_Previews: PreviewProvider {
thumbnailSource: imageSource)))) thumbnailSource: imageSource))))
TimelineReplyView(placement: .timeline, TimelineReplyView(placement: .timeline,
timelineItemReplyDetails: .loaded(sender: .init(id: "", displayName: "Alice"), timelineItemReplyDetails: .loaded(sender: .init(id: "", displayName: "Alice"),
contentType: .location(.init(body: "", geoURI: nil)))) contentType: .location(.init(body: ""))))
} }
.environmentObject(viewModel.context) .environmentObject(viewModel.context)
} }
@@ -65,13 +65,14 @@ struct LocationRoomTimelineView_Previews: PreviewProvider {
isOutgoing: false, isOutgoing: false,
isEditable: false, isEditable: false,
sender: .init(id: "Bob"), sender: .init(id: "Bob"),
content: .init(body: "Fallback geo uri description", geoURI: nil))) content: .init(body: "Fallback geo uri description")))
LocationRoomTimelineView(timelineItem: .init(id: UUID().uuidString, LocationRoomTimelineView(timelineItem: .init(id: UUID().uuidString,
timestamp: "Now", timestamp: "Now",
isOutgoing: false, isOutgoing: false,
isEditable: false, isEditable: false,
sender: .init(id: "Bob"), sender: .init(id: "Bob"),
content: .init(body: "Fallback geo uri description", geoURI: .init(latitude: 41.902782, longitude: 12.496366)))) content: .init(body: "Fallback geo uri description",
geoURI: .init(latitude: 41.902782, longitude: 12.496366))))
} }
} }
+11 -2
View File
@@ -372,7 +372,11 @@ class RoomProxy: RoomProxyProtocol {
return .success(()) return .success(())
} }
func sendLocation(body: String, geoURI: GeoURI) async -> Result<Void, RoomProxyError> { func sendLocation(body: String,
geoURI: GeoURI,
description: String?,
zoomLevel: UInt8?,
assetType: AssetType?) async -> Result<Void, RoomProxyError> {
sendMessageBackgroundTask = backgroundTaskService.startBackgroundTask(withName: backgroundTaskName, isReusable: true) sendMessageBackgroundTask = backgroundTaskService.startBackgroundTask(withName: backgroundTaskName, isReusable: true)
defer { defer {
sendMessageBackgroundTask?.stop() sendMessageBackgroundTask?.stop()
@@ -381,7 +385,12 @@ class RoomProxy: RoomProxyProtocol {
let transactionId = genTransactionId() let transactionId = genTransactionId()
return await Task.dispatch(on: userInitiatedDispatchQueue) { return await Task.dispatch(on: userInitiatedDispatchQueue) {
.success(self.room.sendLocation(body: body, geoUri: geoURI.string, txnId: transactionId)) .success(self.room.sendLocation(body: body,
geoUri: geoURI.string,
description: description,
zoomLevel: zoomLevel,
assetType: assetType,
txnId: transactionId))
} }
} }
@@ -115,7 +115,11 @@ protocol RoomProxyProtocol {
progressSubject: CurrentValueSubject<Double, Never>?, progressSubject: CurrentValueSubject<Double, Never>?,
requestHandle: (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, RoomProxyError> requestHandle: (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, RoomProxyError>
func sendLocation(body: String, geoURI: GeoURI) async -> Result<Void, RoomProxyError> func sendLocation(body: String,
geoURI: GeoURI,
description: String?,
zoomLevel: UInt8?,
assetType: AssetType?) 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
@@ -118,7 +118,7 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
switch timelineItem { switch timelineItem {
case let item as LocationRoomTimelineItem: case let item as LocationRoomTimelineItem:
guard let geoURI = item.content.geoURI else { return .none } guard let geoURI = item.content.geoURI else { return .none }
return .displayLocation(body: item.content.body, geoURI: geoURI) return .displayLocation(body: item.content.body, geoURI: geoURI, description: item.content.description)
default: default:
return await displayMediaActionIfPossible(timelineItem: timelineItem) return await displayMediaActionIfPossible(timelineItem: timelineItem)
} }
@@ -26,7 +26,7 @@ enum RoomTimelineControllerCallback {
enum RoomTimelineControllerAction { enum RoomTimelineControllerAction {
case displayMediaFile(file: MediaFileHandleProxy, title: String?) case displayMediaFile(file: MediaFileHandleProxy, title: String?)
case displayLocation(body: String, geoURI: GeoURI) case displayLocation(body: String, geoURI: GeoURI, description: String?)
case none case none
} }
@@ -17,4 +17,24 @@
struct LocationRoomTimelineItemContent: Hashable { struct LocationRoomTimelineItemContent: Hashable {
let body: String let body: String
let geoURI: GeoURI? let geoURI: GeoURI?
let description: String?
let zoomLevel: UInt8?
let asset: AssetType?
enum AssetType {
case sender
case pin
}
init(body: String,
geoURI: GeoURI? = nil,
description: String? = nil,
zoomLevel: UInt8? = nil,
asset: AssetType? = nil) {
self.body = body
self.geoURI = geoURI
self.description = description
self.zoomLevel = zoomLevel
self.asset = asset
}
} }
@@ -399,7 +399,11 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
} }
private func buildLocationTimelineItemContent(_ locationContent: LocationContent) -> LocationRoomTimelineItemContent { private func buildLocationTimelineItemContent(_ locationContent: LocationContent) -> LocationRoomTimelineItemContent {
LocationRoomTimelineItemContent(body: locationContent.body, geoURI: .init(string: locationContent.geoUri)) LocationRoomTimelineItemContent(body: locationContent.body,
geoURI: .init(string: locationContent.geoUri),
description: locationContent.description,
zoomLevel: locationContent.zoomLevel,
asset: locationContent.asset.map { .init(assetType: $0) })
} }
private func buildFileTimelineItemContent(_ messageContent: FileMessageContent) -> FileRoomTimelineItemContent { private func buildFileTimelineItemContent(_ messageContent: FileMessageContent) -> FileRoomTimelineItemContent {
@@ -528,3 +532,14 @@ struct RoomTimelineItemFactory: RoomTimelineItemFactoryProtocol {
} }
} }
} }
private extension LocationRoomTimelineItemContent.AssetType {
init(assetType: MatrixRustSDK.AssetType) {
switch assetType {
case .sender:
self = .sender
case .pin:
self = .pin
}
}
}
+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.93-alpha exactVersion: 1.0.94-alpha
# path: ../matrix-rust-sdk # path: ../matrix-rust-sdk
DesignKit: DesignKit:
path: DesignKit path: DesignKit