From e48db9495d4e58e4037efc51b4e24457bce20af9 Mon Sep 17 00:00:00 2001 From: Keerthy Date: Mon, 30 Oct 2023 13:54:48 +0530 Subject: [PATCH] Minor refactoring --- MVMCoreUI/Accessibility/AccessibilityHandler.swift | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/MVMCoreUI/Accessibility/AccessibilityHandler.swift b/MVMCoreUI/Accessibility/AccessibilityHandler.swift index 29b727b6..73047b06 100644 --- a/MVMCoreUI/Accessibility/AccessibilityHandler.swift +++ b/MVMCoreUI/Accessibility/AccessibilityHandler.swift @@ -24,9 +24,9 @@ public class AccessibilityOperation: MVMCoreOperation { /** This method will post accessibility notification. - If we have announcement notification then operation will wait untill announcement is finished. */ public override func main() { + guard !checkAndHandleForCancellation() else { return } guard UIAccessibility.isVoiceOverRunning else { markAsFinished() return @@ -37,13 +37,7 @@ public class AccessibilityOperation: MVMCoreOperation { return } UIAccessibility.post(notification: self.notificationType, argument: self.argument) - if self.notificationType == .announcement {///Marking task as finished only if announcement did finished so that user will listen complete announcement. - NotificationCenter.default.addObserver(forName: UIAccessibility.announcementDidFinishNotification, object: nil, queue: .main) { _ in - self.markAsFinished() - } - } else { - self.markAsFinished() - } + self.markAsFinished() } } } @@ -131,16 +125,12 @@ extension AccessibilityHandler { /** This method is used to notify rotor handler about page loaded and capturing the accessibilityId if any. - Will announce text if the page is has announcementText in the response. */ public func onPageNew(rootMolecules: [MoleculeModelProtocol], _ delegateObject: MVMCoreUIDelegateObject?) { previousAccessiblityElement = nil rotorHandler.onPageNew(rootMolecules: rootMolecules, delegateObject) guard let loadObject = (delegateObject?.loadDelegate as? MVMCoreViewControllerProtocol)?.loadObject else { return } accessibilityId = loadObject?.pageJSON?.optionalStringForKey("accessibilityId") - if let announcementText = loadObject?.pageJSON?.optionalStringForKey("announcementText") { - post(notification: .announcement, argument: announcementText) - } self.delegateObject = delegateObject }