Skip to content

Commit

Permalink
Update NotificationSettingsServiceType api
Browse files Browse the repository at this point in the history
  • Loading branch information
alfogrillo committed Jan 31, 2023
1 parent 8d734b9 commit 9b2214a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,13 @@ class MockNotificationSettingsService: NotificationSettingsServiceType, Observab
keywords.remove(keyword)
}

func updatePushRuleActions(for ruleId: String, enabled: Bool, actions: NotificationActions?, completion: ((Result<Void, Error>) -> Void)?) {
func updatePushRuleActions(for ruleId: String, enabled: Bool, actions: NotificationActions?) async throws {
guard let ruleIndex = rules.firstIndex(where: { $0.ruleId == ruleId }) else {
completion?(.success(()))
return
}

rules[ruleIndex] = MockNotificationPushRule(ruleId: ruleId,
enabled: enabled,
actions: actions)
completion?(.success(()))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,5 @@ protocol NotificationSettingsServiceType {
/// - ruleId: The id of the rule.
/// - enabled: Whether the rule should be enabled or disabled.
/// - actions: The actions to update with.
/// - completion: The completion of the operation.
func updatePushRuleActions(for ruleId: String, enabled: Bool, actions: NotificationActions?, completion: ((Result<Void, Error>) -> Void)?)
}

extension NotificationSettingsServiceType {
func updatePushRuleActions(for ruleId: String, enabled: Bool, actions: NotificationActions?) async throws {
try await withCheckedThrowingContinuation { continuation in
updatePushRuleActions(for: ruleId, enabled: enabled, actions: actions) { result in
continuation.resume(with: result)
}
}
}
func updatePushRuleActions(for ruleId: String, enabled: Bool, actions: NotificationActions?) async throws
}

0 comments on commit 9b2214a

Please sign in to comment.