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
@@ -301,10 +301,65 @@ class TimelineController: TimelineControllerProtocol {
}
}
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> {
await activeTimeline.sendAudio(url: url,
audioInfo: audioInfo,
caption: caption,
requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError)
}
func sendFile(url: URL,
fileInfo: MatrixRustSDK.FileInfo,
caption: String?,
requestHandle: @MainActor (any MatrixRustSDK.SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineControllerError> {
await activeTimeline.sendFile(url: url,
fileInfo: fileInfo,
caption: caption,
requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError)
}
func sendImage(url: URL,
thumbnailURL: URL,
imageInfo: MatrixRustSDK.ImageInfo,
caption: String?,
requestHandle: @MainActor (any MatrixRustSDK.SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineControllerError> {
await activeTimeline.sendImage(url: url,
thumbnailURL: thumbnailURL,
imageInfo: imageInfo,
caption: caption,
requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError)
}
func sendVideo(url: URL,
thumbnailURL: URL,
videoInfo: MatrixRustSDK.VideoInfo,
caption: String?,
requestHandle: @MainActor (any MatrixRustSDK.SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineControllerError> {
await activeTimeline.sendVideo(url: url,
thumbnailURL: thumbnailURL,
videoInfo: videoInfo,
caption: caption,
requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError)
}
func sendLocation(body: String,
geoURI: GeoURI,
description: String?,
zoomLevel: UInt8?,
assetType: AssetType?) async -> Result<Void, TimelineControllerError> {
await activeTimeline.sendLocation(body: body, geoURI: geoURI, description: description, zoomLevel: zoomLevel, assetType: assetType).mapError(TimelineControllerError.timelineProxyError)
}
func sendVoiceMessage(url: URL,
audioInfo: MatrixRustSDK.AudioInfo,
waveform: [UInt16],
requestHandle: @MainActor (any MatrixRustSDK.SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineControllerError> {
await activeTimeline.sendVoiceMessage(url: url,
audioInfo: audioInfo,
waveform: waveform) { _ in }
waveform: waveform, requestHandle: requestHandle).mapError(TimelineControllerError.timelineProxyError)
}
// MARK: - Private