mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-22 17:42:45 +02:00
Update recording state after stopping voice broadcast on every cases
This commit is contained in:
+11
-4
@@ -17,6 +17,10 @@
|
||||
import Combine
|
||||
import Foundation
|
||||
|
||||
protocol VoiceBroadcastRecorderServiceDelegate: AnyObject {
|
||||
func voiceBroadcastRecorderService(_ service: VoiceBroadcastRecorderServiceProtocol, didUpdateState state: VoiceBroadcastRecorderState)
|
||||
}
|
||||
|
||||
class VoiceBroadcastRecorderService: VoiceBroadcastRecorderServiceProtocol {
|
||||
|
||||
// MARK: - Properties
|
||||
@@ -37,6 +41,8 @@ class VoiceBroadcastRecorderService: VoiceBroadcastRecorderServiceProtocol {
|
||||
private var chunkFileNumber: Int = 0
|
||||
|
||||
// MARK: Public
|
||||
|
||||
weak var serviceDelegate: VoiceBroadcastRecorderServiceDelegate?
|
||||
|
||||
// MARK: - Setup
|
||||
|
||||
@@ -73,10 +79,12 @@ class VoiceBroadcastRecorderService: VoiceBroadcastRecorderServiceProtocol {
|
||||
resetValues()
|
||||
|
||||
voiceBroadcastService?.stopVoiceBroadcast(success: { [weak self] _ in
|
||||
MXLog.debug("[VoiceBroadcastRecorderService] Stopped")
|
||||
|
||||
guard let self = self else { return }
|
||||
|
||||
// update recording state
|
||||
MXLog.debug("[VoiceBroadcastRecorderService] Stopped")
|
||||
// Update state
|
||||
self.serviceDelegate?.voiceBroadcastRecorderService(self, didUpdateState: .stopped)
|
||||
|
||||
// Send current chunk
|
||||
self.sendChunkFile(at: self.chunkFile.url)
|
||||
@@ -92,7 +100,6 @@ class VoiceBroadcastRecorderService: VoiceBroadcastRecorderServiceProtocol {
|
||||
|
||||
voiceBroadcastService?.pauseVoiceBroadcast(success: { [weak self] _ in
|
||||
guard let self = self else { return }
|
||||
// update recording state
|
||||
|
||||
// Send current chunk
|
||||
self.sendChunkFile(at: self.chunkFile.url)
|
||||
@@ -107,7 +114,7 @@ class VoiceBroadcastRecorderService: VoiceBroadcastRecorderServiceProtocol {
|
||||
try? audioEngine.start()
|
||||
|
||||
voiceBroadcastService?.resumeVoiceBroadcast(success: { _ in
|
||||
// update recording state
|
||||
//
|
||||
}, failure: { error in
|
||||
MXLog.error("[VoiceBroadcastRecorderService] Failed to resume voice broadcast", context: error)
|
||||
})
|
||||
|
||||
+3
@@ -18,6 +18,9 @@ import Combine
|
||||
import Foundation
|
||||
|
||||
protocol VoiceBroadcastRecorderServiceProtocol {
|
||||
/// Service delegate
|
||||
var serviceDelegate: VoiceBroadcastRecorderServiceDelegate? { get set }
|
||||
|
||||
/// Start voice broadcast recording.
|
||||
func startRecordingVoiceBroadcast()
|
||||
|
||||
|
||||
+9
-1
@@ -25,7 +25,7 @@ class VoiceBroadcastRecorderViewModel: VoiceBroadcastRecorderViewModelType, Voic
|
||||
|
||||
// MARK: Private
|
||||
|
||||
private let voiceBroadcastRecorderService: VoiceBroadcastRecorderServiceProtocol
|
||||
private var voiceBroadcastRecorderService: VoiceBroadcastRecorderServiceProtocol
|
||||
|
||||
// MARK: Public
|
||||
|
||||
@@ -37,6 +37,8 @@ class VoiceBroadcastRecorderViewModel: VoiceBroadcastRecorderViewModelType, Voic
|
||||
super.init(initialViewState: VoiceBroadcastRecorderViewState(details: details,
|
||||
recordingState: .stopped,
|
||||
bindings: VoiceBroadcastRecorderViewStateBindings()))
|
||||
|
||||
self.voiceBroadcastRecorderService.serviceDelegate = self
|
||||
process(viewAction: .start)
|
||||
}
|
||||
|
||||
@@ -76,3 +78,9 @@ class VoiceBroadcastRecorderViewModel: VoiceBroadcastRecorderViewModelType, Voic
|
||||
voiceBroadcastRecorderService.resumeRecordingVoiceBroadcast()
|
||||
}
|
||||
}
|
||||
|
||||
extension VoiceBroadcastRecorderViewModel: VoiceBroadcastRecorderServiceDelegate {
|
||||
func voiceBroadcastRecorderService(_ service: VoiceBroadcastRecorderServiceProtocol, didUpdateState state: VoiceBroadcastRecorderState) {
|
||||
self.state.recordingState = state
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user