Add message sending methods to the TimelineController that will automatically use the correct timeline proxy instance internally.

This commit is contained in:
Stefan Ceriu
2025-07-22 14:33:26 +03:00
committed by Stefan Ceriu
parent a4c0b7f91c
commit 35195abc35
4 changed files with 175 additions and 6 deletions
@@ -155,14 +155,96 @@ class MockTimelineController: TimelineControllerProtocol {
inReplyToEventID: String?,
intentionalMentions: IntentionalMentions) async { }
func sendVoiceMessage(url: URL, audioInfo: AudioInfo, waveform: [UInt16]) async -> Result<Void, TimelineProxyError> {
func sendAudio(url: URL,
audioInfo: MatrixRustSDK.AudioInfo,
caption: String?,
requestHandle: @MainActor (any MatrixRustSDK.SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineControllerError> {
if let timelineProxy {
return await timelineProxy.sendVoiceMessage(url: url, audioInfo: audioInfo, waveform: waveform) { _ in }
return await timelineProxy.sendAudio(url: url,
audioInfo: audioInfo,
caption: caption,
requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError)
}
return .success(())
}
func sendFile(url: URL,
fileInfo: MatrixRustSDK.FileInfo,
caption: String?,
requestHandle: @MainActor (any MatrixRustSDK.SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineControllerError> {
if let timelineProxy {
return await timelineProxy.sendFile(url: url,
fileInfo: fileInfo,
caption: caption,
requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError)
}
return .success(())
}
func sendImage(url: URL,
thumbnailURL: URL,
imageInfo: MatrixRustSDK.ImageInfo,
caption: String?,
requestHandle: @MainActor (any MatrixRustSDK.SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineControllerError> {
if let timelineProxy {
return await timelineProxy.sendImage(url: url,
thumbnailURL: thumbnailURL,
imageInfo: imageInfo,
caption: caption,
requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError)
}
return .success(())
}
func sendLocation(body: String,
geoURI: GeoURI,
description: String?,
zoomLevel: UInt8?,
assetType: MatrixRustSDK.AssetType?) async -> Result<Void, TimelineControllerError> {
if let timelineProxy {
return await timelineProxy.sendLocation(body: body,
geoURI: geoURI,
description: description,
zoomLevel: zoomLevel,
assetType: assetType).mapError(TimelineControllerError.timelineProxyError)
}
return .success(())
}
func sendVideo(url: URL,
thumbnailURL: URL,
videoInfo: MatrixRustSDK.VideoInfo,
caption: String?,
requestHandle: @MainActor (any MatrixRustSDK.SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineControllerError> {
if let timelineProxy {
return await timelineProxy.sendVideo(url: url,
thumbnailURL: thumbnailURL,
videoInfo: videoInfo,
caption: caption,
requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError)
}
return .success(())
}
func sendVoiceMessage(url: URL,
audioInfo: MatrixRustSDK.AudioInfo,
waveform: [UInt16],
requestHandle: @MainActor (any MatrixRustSDK.SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineControllerError> {
if let timelineProxy {
return await timelineProxy.sendVoiceMessage(url: url,
audioInfo: audioInfo,
waveform: waveform,
requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError)
}
return .success(())
}
// MARK: - UI Test signalling
/// The cancellable used for UI Tests signalling.