Skip to content

Commit 4187155

Browse files
authored
Enable local echoes for media uploads for all builds. (#3579)
* Enable local echoes for media uploads for all builds. * Update a string.
1 parent 4372048 commit 4187155

13 files changed

+139
-175
lines changed

ElementX/Resources/Localizations/en.lproj/Localizable.strings

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@
352352
"rich_text_editor_unindent" = "Unindent";
353353
"rich_text_editor_url_placeholder" = "Link";
354354
"rich_text_editor_a11y_add_attachment" = "Add attachment";
355-
"rich_text_editor_composer_caption_placeholder" = "Optional caption";
355+
"rich_text_editor_composer_caption_placeholder" = "Add a caption";
356356
"screen_advanced_settings_element_call_base_url" = "Custom Element Call base URL";
357357
"screen_advanced_settings_element_call_base_url_description" = "Set a custom base URL for Element Call.";
358358
"screen_advanced_settings_element_call_base_url_validation_error" = "Invalid URL, please make sure you include the protocol (http/https) and the correct address.";

ElementX/Sources/Generated/Strings.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ internal enum L10n {
796796
internal static var richTextEditorCloseFormattingOptions: String { return L10n.tr("Localizable", "rich_text_editor_close_formatting_options") }
797797
/// Toggle code block
798798
internal static var richTextEditorCodeBlock: String { return L10n.tr("Localizable", "rich_text_editor_code_block") }
799-
/// Optional caption
799+
/// Add a caption
800800
internal static var richTextEditorComposerCaptionPlaceholder: String { return L10n.tr("Localizable", "rich_text_editor_composer_caption_placeholder") }
801801
/// Message…
802802
internal static var richTextEditorComposerPlaceholder: String { return L10n.tr("Localizable", "rich_text_editor_composer_placeholder") }

ElementX/Sources/Mocks/Generated/GeneratedMocks.swift

Lines changed: 100 additions & 100 deletions
Large diffs are not rendered by default.

ElementX/Sources/Screens/MediaUploadPreviewScreen/MediaUploadPreviewScreenViewModel.swift

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,11 @@ class MediaUploadPreviewScreenViewModel: MediaUploadPreviewScreenViewModelType,
4949
switch viewAction {
5050
case .send:
5151
Task {
52-
let progressSubject = AppSettings.isDevelopmentBuild ? nil : CurrentValueSubject<Double, Never>(0.0)
53-
54-
startLoading(progressPublisher: progressSubject?.asCurrentValuePublisher())
52+
startLoading()
5553

5654
switch await mediaUploadingPreprocessor.processMedia(at: url) {
5755
case .success(let mediaInfo):
58-
switch await sendAttachment(mediaInfo: mediaInfo, caption: caption, progressSubject: progressSubject) {
56+
switch await sendAttachment(mediaInfo: mediaInfo, caption: caption) {
5957
case .success:
6058
actionsSubject.send(.dismiss)
6159
case .failure(let error):
@@ -79,7 +77,7 @@ class MediaUploadPreviewScreenViewModel: MediaUploadPreviewScreenViewModelType,
7977

8078
// MARK: - Private
8179

82-
private func sendAttachment(mediaInfo: MediaInfo, caption: String?, progressSubject: CurrentValueSubject<Double, Never>?) async -> Result<Void, TimelineProxyError> {
80+
private func sendAttachment(mediaInfo: MediaInfo, caption: String?) async -> Result<Void, TimelineProxyError> {
8381
let requestHandle: ((SendAttachmentJoinHandleProtocol) -> Void) = { [weak self] handle in
8482
self?.requestHandle = handle
8583
}
@@ -90,42 +88,32 @@ class MediaUploadPreviewScreenViewModel: MediaUploadPreviewScreenViewModelType,
9088
thumbnailURL: thumbnailURL,
9189
imageInfo: imageInfo,
9290
caption: caption,
93-
progressSubject: progressSubject,
9491
requestHandle: requestHandle)
9592
case let .video(videoURL, thumbnailURL, videoInfo):
9693
return await roomProxy.timeline.sendVideo(url: videoURL,
9794
thumbnailURL: thumbnailURL,
9895
videoInfo: videoInfo,
9996
caption: caption,
100-
progressSubject: progressSubject,
10197
requestHandle: requestHandle)
10298
case let .audio(audioURL, audioInfo):
10399
return await roomProxy.timeline.sendAudio(url: audioURL,
104100
audioInfo: audioInfo,
105101
caption: caption,
106-
progressSubject: progressSubject,
107102
requestHandle: requestHandle)
108103
case let .file(fileURL, fileInfo):
109104
return await roomProxy.timeline.sendFile(url: fileURL,
110105
fileInfo: fileInfo,
111106
caption: caption,
112-
progressSubject: progressSubject,
113107
requestHandle: requestHandle)
114108
}
115109
}
116110

117111
private static let loadingIndicatorIdentifier = "\(MediaUploadPreviewScreenViewModel.self)-Loading"
118112

119-
private func startLoading(progressPublisher: CurrentValuePublisher<Double, Never>?) {
120-
let progress: UserIndicator.Progress = if let progressPublisher {
121-
.published(progressPublisher)
122-
} else {
123-
.indeterminate
124-
}
125-
113+
private func startLoading() {
126114
userIndicatorController.submitIndicator(
127115
UserIndicator(id: Self.loadingIndicatorIdentifier,
128-
type: .modal(progress: progress, interactiveDismissDisabled: false, allowsInteraction: true),
116+
type: .modal(progress: .indeterminate, interactiveDismissDisabled: false, allowsInteraction: true),
129117
title: L10n.commonSending,
130118
persistent: true)
131119
)

ElementX/Sources/Services/Timeline/TimelineProxy.swift

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -224,18 +224,15 @@ final class TimelineProxy: TimelineProxyProtocol {
224224
func sendAudio(url: URL,
225225
audioInfo: AudioInfo,
226226
caption: String?,
227-
progressSubject: CurrentValueSubject<Double, Never>?,
228227
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError> {
229228
MXLog.info("Sending audio")
230229

231230
let handle = timeline.sendAudio(url: url.path(percentEncoded: false),
232231
audioInfo: audioInfo,
233232
caption: caption,
234-
formattedCaption: nil,
235-
progressWatcher: UploadProgressListener { progress in
236-
progressSubject?.send(progress)
237-
},
238-
useSendQueue: AppSettings.isDevelopmentBuild)
233+
formattedCaption: nil, // Rust will build this from the caption's markdown.
234+
progressWatcher: nil,
235+
useSendQueue: true)
239236

240237
await requestHandle(handle)
241238

@@ -253,18 +250,15 @@ final class TimelineProxy: TimelineProxyProtocol {
253250
func sendFile(url: URL,
254251
fileInfo: FileInfo,
255252
caption: String?,
256-
progressSubject: CurrentValueSubject<Double, Never>?,
257253
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError> {
258254
MXLog.info("Sending file")
259255

260256
let handle = timeline.sendFile(url: url.path(percentEncoded: false),
261257
fileInfo: fileInfo,
262258
caption: caption,
263-
formattedCaption: nil,
264-
progressWatcher: UploadProgressListener { progress in
265-
progressSubject?.send(progress)
266-
},
267-
useSendQueue: AppSettings.isDevelopmentBuild)
259+
formattedCaption: nil, // Rust will build this from the caption's markdown.
260+
progressWatcher: nil,
261+
useSendQueue: true)
268262

269263
await requestHandle(handle)
270264

@@ -279,24 +273,20 @@ final class TimelineProxy: TimelineProxyProtocol {
279273
return .success(())
280274
}
281275

282-
// swiftlint:disable:next function_parameter_count
283276
func sendImage(url: URL,
284277
thumbnailURL: URL,
285278
imageInfo: ImageInfo,
286279
caption: String?,
287-
progressSubject: CurrentValueSubject<Double, Never>?,
288280
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError> {
289281
MXLog.info("Sending image")
290282

291283
let handle = timeline.sendImage(url: url.path(percentEncoded: false),
292284
thumbnailUrl: thumbnailURL.path(percentEncoded: false),
293285
imageInfo: imageInfo,
294286
caption: caption,
295-
formattedCaption: nil,
296-
progressWatcher: UploadProgressListener { progress in
297-
progressSubject?.send(progress)
298-
},
299-
useSendQueue: AppSettings.isDevelopmentBuild)
287+
formattedCaption: nil, // Rust will build this from the caption's markdown.
288+
progressWatcher: nil,
289+
useSendQueue: true)
300290

301291
await requestHandle(handle)
302292

@@ -334,19 +324,16 @@ final class TimelineProxy: TimelineProxyProtocol {
334324
thumbnailURL: URL,
335325
videoInfo: VideoInfo,
336326
caption: String?,
337-
progressSubject: CurrentValueSubject<Double, Never>?,
338327
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError> {
339328
MXLog.info("Sending video")
340329

341330
let handle = timeline.sendVideo(url: url.path(percentEncoded: false),
342331
thumbnailUrl: thumbnailURL.path(percentEncoded: false),
343332
videoInfo: videoInfo,
344333
caption: caption,
345-
formattedCaption: nil,
346-
progressWatcher: UploadProgressListener { progress in
347-
progressSubject?.send(progress)
348-
},
349-
useSendQueue: AppSettings.isDevelopmentBuild)
334+
formattedCaption: nil, // Rust will build this from the caption's markdown.
335+
progressWatcher: nil,
336+
useSendQueue: true)
350337

351338
await requestHandle(handle)
352339

@@ -364,7 +351,6 @@ final class TimelineProxy: TimelineProxyProtocol {
364351
func sendVoiceMessage(url: URL,
365352
audioInfo: AudioInfo,
366353
waveform: [UInt16],
367-
progressSubject: CurrentValueSubject<Double, Never>?,
368354
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError> {
369355
MXLog.info("Sending voice message")
370356

@@ -373,10 +359,8 @@ final class TimelineProxy: TimelineProxyProtocol {
373359
waveform: waveform,
374360
caption: nil,
375361
formattedCaption: nil,
376-
progressWatcher: UploadProgressListener { progress in
377-
progressSubject?.send(progress)
378-
},
379-
useSendQueue: AppSettings.isDevelopmentBuild)
362+
progressWatcher: nil,
363+
useSendQueue: true)
380364

381365
await requestHandle(handle)
382366

ElementX/Sources/Services/Timeline/TimelineProxyProtocol.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,17 @@ protocol TimelineProxyProtocol {
5252
func sendAudio(url: URL,
5353
audioInfo: AudioInfo,
5454
caption: String?,
55-
progressSubject: CurrentValueSubject<Double, Never>?,
5655
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError>
5756

5857
func sendFile(url: URL,
5958
fileInfo: FileInfo,
6059
caption: String?,
61-
progressSubject: CurrentValueSubject<Double, Never>?,
6260
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError>
6361

64-
// swiftlint:disable:next function_parameter_count
6562
func sendImage(url: URL,
6663
thumbnailURL: URL,
6764
imageInfo: ImageInfo,
6865
caption: String?,
69-
progressSubject: CurrentValueSubject<Double, Never>?,
7066
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError>
7167

7268
func sendLocation(body: String,
@@ -75,18 +71,15 @@ protocol TimelineProxyProtocol {
7571
zoomLevel: UInt8?,
7672
assetType: AssetType?) async -> Result<Void, TimelineProxyError>
7773

78-
// swiftlint:disable:next function_parameter_count
7974
func sendVideo(url: URL,
8075
thumbnailURL: URL,
8176
videoInfo: VideoInfo,
8277
caption: String?,
83-
progressSubject: CurrentValueSubject<Double, Never>?,
8478
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError>
8579

8680
func sendVoiceMessage(url: URL,
8781
audioInfo: AudioInfo,
8882
waveform: [UInt16],
89-
progressSubject: CurrentValueSubject<Double, Never>?,
9083
requestHandle: @MainActor (SendAttachmentJoinHandleProtocol) -> Void) async -> Result<Void, TimelineProxyError>
9184

9285
func sendReadReceipt(for eventID: String, type: ReceiptType) async -> Result<Void, TimelineProxyError>

ElementX/Sources/Services/VoiceMessage/VoiceMessageRecorder.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,7 @@ class VoiceMessageRecorder: VoiceMessageRecorderProtocol {
178178

179179
let result = await roomProxy.timeline.sendVoiceMessage(url: oggFile,
180180
audioInfo: audioInfo,
181-
waveform: waveform,
182-
progressSubject: nil) { _ in }
181+
waveform: waveform) { _ in }
183182

184183
if case .failure(let error) = result {
185184
MXLog.error("Failed to send the voice message. \(error)")
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 2 additions & 2 deletions
Loading

0 commit comments

Comments
 (0)