mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 11:58:32 +00:00
Enable local echoes for media uploads on development builds. (#3514)
* Enable local echoes for media uploads on development builds. * Use media sizes when loading timeline items so they can take advantage of the cached local echo data.
This commit is contained in:
+11
-5
@@ -45,9 +45,9 @@ class MediaUploadPreviewScreenViewModel: MediaUploadPreviewScreenViewModelType,
|
||||
switch viewAction {
|
||||
case .send:
|
||||
Task {
|
||||
let progressSubject = CurrentValueSubject<Double, Never>(0.0)
|
||||
let progressSubject = AppSettings.isDevelopmentBuild ? nil : CurrentValueSubject<Double, Never>(0.0)
|
||||
|
||||
startLoading(progressPublisher: progressSubject.asCurrentValuePublisher())
|
||||
startLoading(progressPublisher: progressSubject?.asCurrentValuePublisher())
|
||||
|
||||
switch await mediaUploadingPreprocessor.processMedia(at: url) {
|
||||
case .success(let mediaInfo):
|
||||
@@ -75,7 +75,7 @@ class MediaUploadPreviewScreenViewModel: MediaUploadPreviewScreenViewModelType,
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func sendAttachment(mediaInfo: MediaInfo, progressSubject: CurrentValueSubject<Double, Never>) async -> Result<Void, TimelineProxyError> {
|
||||
private func sendAttachment(mediaInfo: MediaInfo, progressSubject: CurrentValueSubject<Double, Never>?) async -> Result<Void, TimelineProxyError> {
|
||||
let requestHandle: ((SendAttachmentJoinHandleProtocol) -> Void) = { [weak self] handle in
|
||||
self?.requestHandle = handle
|
||||
}
|
||||
@@ -94,10 +94,16 @@ class MediaUploadPreviewScreenViewModel: MediaUploadPreviewScreenViewModelType,
|
||||
|
||||
private static let loadingIndicatorIdentifier = "\(MediaUploadPreviewScreenViewModel.self)-Loading"
|
||||
|
||||
private func startLoading(progressPublisher: CurrentValuePublisher<Double, Never>) {
|
||||
private func startLoading(progressPublisher: CurrentValuePublisher<Double, Never>?) {
|
||||
let progress: UserIndicator.Progress = if let progressPublisher {
|
||||
.published(progressPublisher)
|
||||
} else {
|
||||
.indeterminate
|
||||
}
|
||||
|
||||
userIndicatorController.submitIndicator(
|
||||
UserIndicator(id: Self.loadingIndicatorIdentifier,
|
||||
type: .modal(progress: .published(progressPublisher), interactiveDismissDisabled: false, allowsInteraction: true),
|
||||
type: .modal(progress: progress, interactiveDismissDisabled: false, allowsInteraction: true),
|
||||
title: L10n.commonSending,
|
||||
persistent: true)
|
||||
)
|
||||
|
||||
+33
-24
@@ -17,19 +17,12 @@ struct ImageRoomTimelineView: View {
|
||||
var body: some View {
|
||||
TimelineStyler(timelineItem: timelineItem) {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
LoadableImage(mediaSource: source,
|
||||
mediaType: .timelineItem,
|
||||
blurhash: timelineItem.content.blurhash,
|
||||
mediaProvider: context.mediaProvider) {
|
||||
placeholder
|
||||
}
|
||||
.timelineMediaFrame(height: timelineItem.content.height,
|
||||
aspectRatio: timelineItem.content.aspectRatio)
|
||||
.accessibilityElement(children: .ignore)
|
||||
.accessibilityLabel(L10n.commonImage)
|
||||
// This clip shape is distinct from the one in the styler as that one
|
||||
// operates on the entire message so wouldn't round the bottom corners.
|
||||
.clipShape(RoundedRectangle(cornerRadius: hasMediaCaption ? 6 : 0))
|
||||
loadableImage
|
||||
.accessibilityElement(children: .ignore)
|
||||
.accessibilityLabel(L10n.commonImage)
|
||||
// This clip shape is distinct from the one in the styler as that one
|
||||
// operates on the entire message so wouldn't round the bottom corners.
|
||||
.clipShape(RoundedRectangle(cornerRadius: hasMediaCaption ? 6 : 0))
|
||||
|
||||
if let attributedCaption = timelineItem.content.formattedCaption {
|
||||
FormattedBodyText(attributedString: attributedCaption,
|
||||
@@ -44,15 +37,32 @@ struct ImageRoomTimelineView: View {
|
||||
}
|
||||
}
|
||||
|
||||
var source: MediaSourceProxy {
|
||||
guard timelineItem.content.contentType != .gif, let thumbnailSource = timelineItem.content.thumbnailSource else {
|
||||
return timelineItem.content.source
|
||||
@ViewBuilder
|
||||
private var loadableImage: some View {
|
||||
if timelineItem.content.contentType == .gif {
|
||||
LoadableImage(mediaSource: timelineItem.content.source,
|
||||
mediaType: .timelineItem,
|
||||
blurhash: timelineItem.content.blurhash,
|
||||
size: timelineItem.content.size,
|
||||
mediaProvider: context.mediaProvider) {
|
||||
placeholder
|
||||
}
|
||||
.timelineMediaFrame(height: timelineItem.content.thumbnailSize?.height,
|
||||
aspectRatio: timelineItem.content.aspectRatio)
|
||||
} else {
|
||||
LoadableImage(mediaSource: timelineItem.content.thumbnailSource ?? timelineItem.content.source,
|
||||
mediaType: .timelineItem,
|
||||
blurhash: timelineItem.content.blurhash,
|
||||
size: timelineItem.content.thumbnailSize ?? timelineItem.content.size,
|
||||
mediaProvider: context.mediaProvider) {
|
||||
placeholder
|
||||
}
|
||||
.timelineMediaFrame(height: timelineItem.content.thumbnailSize?.height ?? timelineItem.content.size?.height,
|
||||
aspectRatio: timelineItem.content.thumbnailAspectRatio ?? timelineItem.content.aspectRatio)
|
||||
}
|
||||
|
||||
return thumbnailSource
|
||||
}
|
||||
|
||||
var placeholder: some View {
|
||||
|
||||
private var placeholder: some View {
|
||||
Rectangle()
|
||||
.foregroundColor(timelineItem.isOutgoing ? .compound._bgBubbleOutgoing : .compound._bgBubbleIncoming)
|
||||
.opacity(0.3)
|
||||
@@ -100,8 +110,8 @@ struct ImageRoomTimelineView_Previews: PreviewProvider, TestablePreview {
|
||||
sender: .init(id: "Bob"),
|
||||
content: .init(filename: "Blurhashed.jpg",
|
||||
source: MediaSourceProxy(url: .picturesDirectory, mimeType: "image/gif"),
|
||||
thumbnailSource: nil,
|
||||
aspectRatio: 0.7,
|
||||
thumbnailSource: nil,
|
||||
blurhash: "L%KUc%kqS$RP?Ks,WEf8OlrqaekW",
|
||||
contentType: .gif)))
|
||||
|
||||
@@ -115,10 +125,9 @@ struct ImageRoomTimelineView_Previews: PreviewProvider, TestablePreview {
|
||||
content: .init(filename: "Blurhashed.jpg",
|
||||
caption: "This is a great image 😎",
|
||||
source: MediaSourceProxy(url: .picturesDirectory, mimeType: "image/png"),
|
||||
thumbnailSource: nil,
|
||||
width: 50,
|
||||
height: 50,
|
||||
size: .init(width: 50, height: 50),
|
||||
aspectRatio: 1,
|
||||
thumbnailSource: nil,
|
||||
blurhash: "L%KUc%kqS$RP?Ks,WEf8OlrqaekW",
|
||||
contentType: .gif)))
|
||||
}
|
||||
|
||||
+2
-1
@@ -17,10 +17,11 @@ struct StickerRoomTimelineView: View {
|
||||
LoadableImage(url: timelineItem.imageURL,
|
||||
mediaType: .timelineItem,
|
||||
blurhash: timelineItem.blurhash,
|
||||
size: timelineItem.size,
|
||||
mediaProvider: context.mediaProvider) {
|
||||
placeholder
|
||||
}
|
||||
.timelineMediaFrame(height: timelineItem.height,
|
||||
.timelineMediaFrame(height: timelineItem.size?.height,
|
||||
aspectRatio: timelineItem.aspectRatio)
|
||||
.accessibilityElement(children: .ignore)
|
||||
.accessibilityLabel("\(L10n.commonSticker), \(timelineItem.body)")
|
||||
|
||||
+3
-2
@@ -18,7 +18,7 @@ struct VideoRoomTimelineView: View {
|
||||
TimelineStyler(timelineItem: timelineItem) {
|
||||
VStack(alignment: .leading, spacing: 4) {
|
||||
thumbnail
|
||||
.timelineMediaFrame(height: timelineItem.content.height,
|
||||
.timelineMediaFrame(height: timelineItem.content.thumbnailSize?.height,
|
||||
aspectRatio: timelineItem.content.aspectRatio)
|
||||
.accessibilityElement(children: .ignore)
|
||||
.accessibilityLabel(L10n.commonVideo)
|
||||
@@ -45,6 +45,7 @@ struct VideoRoomTimelineView: View {
|
||||
LoadableImage(mediaSource: thumbnailSource,
|
||||
mediaType: .timelineItem,
|
||||
blurhash: timelineItem.content.blurhash,
|
||||
size: timelineItem.content.thumbnailSize,
|
||||
mediaProvider: context.mediaProvider) { imageView in
|
||||
imageView
|
||||
.overlay { playIcon }
|
||||
@@ -114,8 +115,8 @@ struct VideoRoomTimelineView_Previews: PreviewProvider, TestablePreview {
|
||||
content: .init(filename: "Blurhashed.mp4",
|
||||
duration: 23,
|
||||
source: nil,
|
||||
thumbnailSource: nil,
|
||||
aspectRatio: 0.7,
|
||||
thumbnailSource: nil,
|
||||
blurhash: "L%KUc%kqS$RP?Ks,WEf8OlrqaekW")))
|
||||
|
||||
VideoRoomTimelineView(timelineItem: VideoRoomTimelineItem(id: .randomEvent,
|
||||
|
||||
Reference in New Issue
Block a user