From 8fd872ad04deca617c4a00bf293433bc956f7989 Mon Sep 17 00:00:00 2001 From: martinmitrevski Date: Tue, 19 Dec 2023 15:19:27 +0100 Subject: [PATCH] Fixed bugs --- .../Composer/MessageComposerViewModel+Recording.swift | 1 + .../VoiceRecordingContainerView.swift | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/Sources/StreamChatSwiftUI/ChatChannel/Composer/MessageComposerViewModel+Recording.swift b/Sources/StreamChatSwiftUI/ChatChannel/Composer/MessageComposerViewModel+Recording.swift index a62e69e7..ae6e3c3d 100644 --- a/Sources/StreamChatSwiftUI/ChatChannel/Composer/MessageComposerViewModel+Recording.swift +++ b/Sources/StreamChatSwiftUI/ChatChannel/Composer/MessageComposerViewModel+Recording.swift @@ -52,6 +52,7 @@ extension MessageComposerViewModel: AudioRecordingDelegate { ) if self.recordingState == .stopped { self.pendingAudioRecording = recording + self.audioRecordingInfo.waveform = waveform } else { self.addedVoiceRecordings.append(recording) self.recordingState = .initial diff --git a/Sources/StreamChatSwiftUI/ChatChannel/MessageList/AsyncVoiceMessages/VoiceRecordingContainerView.swift b/Sources/StreamChatSwiftUI/ChatChannel/MessageList/AsyncVoiceMessages/VoiceRecordingContainerView.swift index cd737911..392c8d5f 100644 --- a/Sources/StreamChatSwiftUI/ChatChannel/MessageList/AsyncVoiceMessages/VoiceRecordingContainerView.swift +++ b/Sources/StreamChatSwiftUI/ChatChannel/MessageList/AsyncVoiceMessages/VoiceRecordingContainerView.swift @@ -73,6 +73,7 @@ struct VoiceRecordingView: View { @Injected(\.images) var images @State var isPlaying: Bool = false + @State var loading: Bool = false @State var rate: AudioPlaybackRate = .normal @ObservedObject var handler: VoiceRecordingHandler @@ -102,6 +103,10 @@ struct VoiceRecordingView: View { .foregroundColor(.primary) .modifier(ShadowViewModifier(firstRadius: 2, firstY: 4)) }) + .opacity(loading ? 0 : 1) + .overlay( + loading ? ProgressView() : nil + ) VStack(alignment: .leading, spacing: 4) { Text( @@ -162,6 +167,12 @@ struct VoiceRecordingView: View { } .onReceive(handler.$context, perform: { value in guard value.assetLocation == addedVoiceRecording.url else { return } + if value.state == .loading { + loading = true + return + } else if loading { + loading = false + } if value.state == .stopped || value.state == .paused { isPlaying = false } else if value.state == .playing {