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) {