Update NotificationSettingsServiceType

This commit is contained in:
Alfonso Grillo
2023-01-27 13:27:18 +01:00
parent 0e8c78be07
commit c295cf88bb
4 changed files with 13 additions and 6 deletions
@@ -70,12 +70,15 @@ class MXNotificationSettingsService: NotificationSettingsServiceType {
session.notificationCenter.removeRule(rule)
}
func updatePushRuleActions(for ruleId: String, enabled: Bool, actions: NotificationActions?) {
func updatePushRuleActions(for ruleId: String, enabled: Bool, actions: NotificationActions?, completion: ((Result<Void, Error>) -> Void)?) {
guard let rule = session.notificationCenter.rule(byId: ruleId) else {
return
}
session.notificationCenter.enableRule(rule, isEnabled: enabled)
session.notificationCenter.enableRule(rule, isEnabled: enabled) { error in
#warning("complete here")
print("*** enable error: \(error)")
}
if let actions = actions {
session.notificationCenter.updatePushRuleActions(ruleId,
@@ -44,5 +44,6 @@ class MockNotificationSettingsService: NotificationSettingsServiceType, Observab
keywords.remove(keyword)
}
func updatePushRuleActions(for ruleId: String, enabled: Bool, actions: NotificationActions?) { }
func updatePushRuleActions(for ruleId: String, enabled: Bool, actions: NotificationActions?, completion: ((Result<Void, Error>) -> Void)?) {
}
}
@@ -40,5 +40,6 @@ protocol NotificationSettingsServiceType {
/// - ruleId: The id of the rule.
/// - enabled: Whether the rule should be enabled or disabled.
/// - actions: The actions to update with.
func updatePushRuleActions(for ruleId: String, enabled: Bool, actions: NotificationActions?)
/// - completion: The completion of the operation.
func updatePushRuleActions(for ruleId: String, enabled: Bool, actions: NotificationActions?, completion: ((Result<Void, Error>) -> Void)?)
}