diff --git a/MVMCoreUI/Alerts/MVMCoreAlertHandler.h b/MVMCoreUI/Alerts/MVMCoreAlertHandler.h index 522c5740..311b0c61 100644 --- a/MVMCoreUI/Alerts/MVMCoreAlertHandler.h +++ b/MVMCoreUI/Alerts/MVMCoreAlertHandler.h @@ -104,6 +104,9 @@ /// 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; + /// Removes a scheduled top alert given its top alert object. - (void)removeTopAlertForObject:(nonnull MVMCoreTopAlertObject *)topAlertObject; diff --git a/MVMCoreUI/Alerts/MVMCoreAlertHandler.m b/MVMCoreUI/Alerts/MVMCoreAlertHandler.m index 8b4b02c7..977e6293 100644 --- a/MVMCoreUI/Alerts/MVMCoreAlertHandler.m +++ b/MVMCoreUI/Alerts/MVMCoreAlertHandler.m @@ -239,6 +239,19 @@ } } +- (void)hideTopAlertViewOfType:(nullable NSString *)type { + if (type) { + for (MVMCoreTopAlertOperation *operation in self.topAlertQueue.operations) { + + // Cancel all operations of this type. + if ([operation.topAlertObject.type isEqualToString:type]) { + operation.reAddAfterCancel = NO; + [operation cancel]; + } + } + } +} + - (void)removeTopAlertForObject:(MVMCoreTopAlertObject *)topAlertObject { for (MVMCoreTopAlertOperation *operation in self.topAlertQueue.operations) { // Finds an cancels top alerts associated with the object. diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift index 454ea7a2..0328f03c 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView+Extension.swift @@ -31,7 +31,7 @@ public extension MVMCoreUITopAlertView { // Dismiss any top alerts that server wants us to dismiss/ if let disableType = loadObject.responseInfoMap?.optionalStringForKey("disableType") { - MVMCoreAlertHandler.shared()?.hidePersistentTopAlertView(ofType: disableType) + MVMCoreAlertHandler.shared()?.hideTopAlertView(ofType: disableType) } // Show any new top alert.