mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-29 04:36:58 +02:00
Delete an existing broadcast (#7219)
This commit is contained in:
+4
@@ -56,6 +56,10 @@ final class VoiceBroadcastPlaybackCoordinator: Coordinator, Presentable {
|
||||
|
||||
}
|
||||
|
||||
deinit {
|
||||
viewModel.context.send(viewAction: .redact)
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
func start() { }
|
||||
|
||||
+27
-7
@@ -29,7 +29,19 @@ import Foundation
|
||||
}
|
||||
}
|
||||
}
|
||||
var coordinatorsForEventIdentifiers = [String: VoiceBroadcastPlaybackCoordinator]()
|
||||
private var coordinatorsForEventIdentifiers = [String: VoiceBroadcastPlaybackCoordinator]() {
|
||||
didSet {
|
||||
if !self.coordinatorsForEventIdentifiers.isEmpty && self.redactionsListener == nil {
|
||||
redactionsListener = session?.listenToEvents([MXEventType(identifier: kMXEventTypeStringRoomRedaction)], self.handleEvent)
|
||||
}
|
||||
|
||||
if self.coordinatorsForEventIdentifiers.isEmpty && self.redactionsListener != nil {
|
||||
session?.removeListener(self.redactionsListener)
|
||||
self.redactionsListener = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
private var redactionsListener: Any?
|
||||
|
||||
private override init() { }
|
||||
|
||||
@@ -58,16 +70,24 @@ import Foundation
|
||||
return coordinator.toPresentable()
|
||||
|
||||
}
|
||||
|
||||
/// Retrieve the voiceBroadcast timeline coordinator for the given event or nil if it hasn't been created yet
|
||||
func voiceBroadcastPlaybackCoordinatorForEventIdentifier(_ eventIdentifier: String) -> VoiceBroadcastPlaybackCoordinator? {
|
||||
coordinatorsForEventIdentifiers[eventIdentifier]
|
||||
}
|
||||
|
||||
|
||||
/// Pause current voice broadcast playback.
|
||||
@objc public func pausePlaying() {
|
||||
coordinatorsForEventIdentifiers.forEach { _, coordinator in
|
||||
coordinator.pausePlaying()
|
||||
}
|
||||
}
|
||||
|
||||
private func handleEvent(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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user