From 2b5ce09b104585f2365c526a9585a5bf49103c47 Mon Sep 17 00:00:00 2001 From: Krishna Kishore Bandaru Date: Thu, 11 Nov 2021 23:11:31 +0530 Subject: [PATCH] added new function hideTopAlertViewOfType --- MVMCoreUI/Alerts/MVMCoreAlertHandler.h | 3 +++ MVMCoreUI/Alerts/MVMCoreAlertHandler.m | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/MVMCoreUI/Alerts/MVMCoreAlertHandler.h b/MVMCoreUI/Alerts/MVMCoreAlertHandler.h index 0d9bc7cb..311b0c61 100644 --- a/MVMCoreUI/Alerts/MVMCoreAlertHandler.h +++ b/MVMCoreUI/Alerts/MVMCoreAlertHandler.h @@ -101,6 +101,9 @@ /// Hides the current alert view. - (void)hideTopAlertView; +/// Hides a persistent alert based on the type string. +- (void)hidePersistentTopAlertViewOfType:(nullable NSString *)type; + /// Hides a alert based on the type string. - (void)hideTopAlertViewOfType:(nullable NSString *)type; diff --git a/MVMCoreUI/Alerts/MVMCoreAlertHandler.m b/MVMCoreUI/Alerts/MVMCoreAlertHandler.m index 20ea95a1..977e6293 100644 --- a/MVMCoreUI/Alerts/MVMCoreAlertHandler.m +++ b/MVMCoreUI/Alerts/MVMCoreAlertHandler.m @@ -226,6 +226,19 @@ return hasAlert; } +- (void)hidePersistentTopAlertViewOfType:(nullable NSString *)type { + if (type) { + for (MVMCoreTopAlertOperation *operation in self.topAlertQueue.operations) { + + // Cancel all persistent operations of this type. + if (operation.topAlertObject.persistent && [operation.topAlertObject.type isEqualToString:type]) { + operation.reAddAfterCancel = NO; + [operation cancel]; + } + } + } +} + - (void)hideTopAlertViewOfType:(nullable NSString *)type { if (type) { for (MVMCoreTopAlertOperation *operation in self.topAlertQueue.operations) {