mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-24 18:42:47 +02:00
Delete during broadcasting (#7227)
This commit is contained in:
+4
@@ -50,6 +50,10 @@ final class VoiceBroadcastRecorderCoordinator: Coordinator, Presentable {
|
||||
recorderService: voiceBroadcastRecorderService)
|
||||
voiceBroadcastRecorderViewModel = viewModel
|
||||
}
|
||||
|
||||
deinit {
|
||||
voiceBroadcastRecorderService.cancelRecordingVoiceBroadcast()
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
|
||||
+26
-1
@@ -33,7 +33,19 @@ import Foundation
|
||||
}
|
||||
}
|
||||
}
|
||||
var coordinatorsForEventIdentifiers = [String: VoiceBroadcastRecorderCoordinator]()
|
||||
private var coordinatorsForEventIdentifiers = [String: VoiceBroadcastRecorderCoordinator]() {
|
||||
didSet {
|
||||
if !self.coordinatorsForEventIdentifiers.isEmpty && self.redactionsListener == nil {
|
||||
redactionsListener = session?.listenToEvents([MXEventType(identifier: kMXEventTypeStringRoomRedaction)], self.handleRedactedEvent)
|
||||
}
|
||||
|
||||
if self.coordinatorsForEventIdentifiers.isEmpty && self.redactionsListener != nil {
|
||||
session?.removeListener(self.redactionsListener)
|
||||
self.redactionsListener = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
private var redactionsListener: Any?
|
||||
|
||||
// MARK: Private
|
||||
private var currentEventIdentifier: String?
|
||||
@@ -83,4 +95,17 @@ import Foundation
|
||||
|
||||
return coordinatorsForEventIdentifiers[currentEventIdentifier]
|
||||
}
|
||||
|
||||
private func handleRedactedEvent(event: MXEvent, direction: MXTimelineDirection, customObject: Any?) {
|
||||
if direction == .backwards {
|
||||
// ignore backwards events
|
||||
return
|
||||
}
|
||||
|
||||
var coordinator = coordinatorsForEventIdentifiers.removeValue(forKey: event.redacts)
|
||||
|
||||
coordinator?.toPresentable().dismiss(animated: false) {
|
||||
coordinator = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+15
@@ -151,6 +151,21 @@ class VoiceBroadcastRecorderService: VoiceBroadcastRecorderServiceProtocol {
|
||||
})
|
||||
}
|
||||
|
||||
func cancelRecordingVoiceBroadcast() {
|
||||
MXLog.debug("[VoiceBroadcastRecorderService] Cancel recording voice broadcast")
|
||||
audioEngine.stop()
|
||||
audioEngine.inputNode.removeTap(onBus: audioNodeBus)
|
||||
UIApplication.shared.isIdleTimerDisabled = false
|
||||
|
||||
// Remove current chunk
|
||||
if self.chunkFile != nil {
|
||||
self.deleteRecording(at: self.chunkFile.url)
|
||||
self.chunkFile = nil
|
||||
}
|
||||
|
||||
self.tearDownVoiceBroadcastService()
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
/// Reset chunk values.
|
||||
private func resetValues() {
|
||||
|
||||
+3
@@ -36,4 +36,7 @@ protocol VoiceBroadcastRecorderServiceProtocol {
|
||||
|
||||
/// Resume voice broadcast recording after paused it.
|
||||
func resumeRecordingVoiceBroadcast()
|
||||
|
||||
/// Cancel voice broadcast recording after redacted it.
|
||||
func cancelRecordingVoiceBroadcast()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user