bugfixes for delegate, logging, and legacy

This commit is contained in:
Scott Pfeil 2023-04-18 18:21:57 -04:00
parent ba14681a39
commit e61b9ed8f1

View File

@ -25,7 +25,6 @@ public class AlertOperation: MVMCoreOperation {
}
private var properties = Properties()
//private var observer: NSKeyValueObservation?
private var cancellable: Cancellable?
public let alertController: AlertController
@ -89,26 +88,25 @@ public class AlertOperation: MVMCoreOperation {
stopObservingAlertView()
cancellable = alertController.publisher(for: \AlertController.visible).sink() { [weak self] visible in
guard let self = self else { return }
Task { @MainActor in
Task {
guard await self.properties.getIsDisplayed() != visible else { return }
await self.properties.set(displayed: visible)
if visible {
self.alertObject.alertDelegate?.alertShown(self.alertController)
} else {
self.alertObject.alertDelegate?.alertDismissed(self.alertController)
// Is visible was set to NO, meaning that the alertview is no longer visible.
self.stopObservingAlertView()
self.markAsFinished()
Task { @MainActor in
if visible {
self.alertObject.alertDelegate?.alertShown(self.alertController)
} else {
self.alertObject.alertDelegate?.alertDismissed(self.alertController)
// Is visible was set to NO, meaning that the alertview is no longer visible.
self.stopObservingAlertView()
self.markAsFinished()
}
}
}
}
// observer = alertController.observe(\AlertController.visible, options: [.old, .new]) { [weak self] (object, change) in
//
// }
}
private func stopObservingAlertView() {
//observer?.invalidate()
cancellable?.cancel()
}
}