mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-20 08:32:53 +02:00
Start poll push rule sync logic
This commit is contained in:
+44
-3
@@ -113,12 +113,32 @@ final class NotificationSettingsViewModel: NotificationSettingsViewModelType, Ob
|
||||
switch ruleID {
|
||||
case .keywords: // Keywords is handled differently to other settings
|
||||
updateKeywords(isChecked: isChecked)
|
||||
|
||||
case .oneToOneRoom:
|
||||
updatePushActions(for: [ruleID, .oneToOnePollStart, .msc3930oneToOnePollStart, .oneToOnePollEnd, .msc3930oneToOnePollEnd], enabled: enabled, standardActions: standardActions)
|
||||
updatePushAction(
|
||||
id: ruleID,
|
||||
enabled: enabled,
|
||||
standardActions: standardActions,
|
||||
then: [.oneToOnePollStart, .msc3930oneToOnePollStart, .oneToOnePollEnd, .msc3930oneToOnePollEnd],
|
||||
completion: nil
|
||||
)
|
||||
|
||||
case .allOtherMessages:
|
||||
updatePushActions(for: [ruleID, .pollStart, .msc3930pollStart, .pollEnd, .msc3930pollEnd], enabled: enabled, standardActions: standardActions)
|
||||
updatePushAction(
|
||||
id: ruleID,
|
||||
enabled: enabled,
|
||||
standardActions: standardActions,
|
||||
then: [.pollStart, .msc3930pollStart, .pollEnd, .msc3930pollEnd],
|
||||
completion: nil
|
||||
)
|
||||
|
||||
default:
|
||||
updatePushActions(for: [ruleID], enabled: enabled, standardActions: standardActions)
|
||||
notificationSettingsService.updatePushRuleActions(
|
||||
for: ruleID.rawValue,
|
||||
enabled: enabled,
|
||||
actions: standardActions.actions,
|
||||
completion: nil
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,6 +177,27 @@ private extension NotificationSettingsViewModel {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func updatePushAction(id: NotificationPushRuleId,
|
||||
enabled: Bool,
|
||||
standardActions: NotificationStandardActions,
|
||||
then rules: [NotificationPushRuleId],
|
||||
completion: ((Result<Void, Error>) -> Void)?) {
|
||||
|
||||
notificationSettingsService.updatePushRuleActions(
|
||||
for: id.rawValue,
|
||||
enabled: enabled,
|
||||
actions: standardActions.actions) { [weak self] result in
|
||||
switch result {
|
||||
case .success:
|
||||
#warning("TODO: sync the update of these rules with the completion")
|
||||
self?.updatePushActions(for: rules, enabled: enabled, standardActions: standardActions)
|
||||
completion?(.success(()))
|
||||
case .failure(let error):
|
||||
completion?(.failure(error))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func updatePushActions(for ids: [NotificationPushRuleId], enabled: Bool, standardActions: NotificationStandardActions) {
|
||||
for id in ids {
|
||||
|
||||
Reference in New Issue
Block a user