diff --git a/RiotSwiftUI/Modules/Settings/Notifications/Model/NotificationPushRuleIds.swift b/RiotSwiftUI/Modules/Settings/Notifications/Model/NotificationPushRuleIds.swift index 27d8b9e41..46cca080e 100644 --- a/RiotSwiftUI/Modules/Settings/Notifications/Model/NotificationPushRuleIds.swift +++ b/RiotSwiftUI/Modules/Settings/Notifications/Model/NotificationPushRuleIds.swift @@ -82,4 +82,15 @@ extension NotificationPushRuleId { return "" } } + + var syncedRules: [NotificationPushRuleId] { + switch self { + case .oneToOneRoom: + return [.oneToOnePollStart, .msc3930oneToOnePollStart, .oneToOnePollEnd, .msc3930oneToOnePollEnd] + case .allOtherMessages: + return [.pollStart, .msc3930pollStart, .pollEnd, .msc3930pollEnd] + default: + return [] + } + } } diff --git a/RiotSwiftUI/Modules/Settings/Notifications/ViewModel/NotificationSettingsViewModel.swift b/RiotSwiftUI/Modules/Settings/Notifications/ViewModel/NotificationSettingsViewModel.swift index bfc262c01..0dac38eb8 100644 --- a/RiotSwiftUI/Modules/Settings/Notifications/ViewModel/NotificationSettingsViewModel.swift +++ b/RiotSwiftUI/Modules/Settings/Notifications/ViewModel/NotificationSettingsViewModel.swift @@ -114,20 +114,12 @@ final class NotificationSettingsViewModel: NotificationSettingsViewModelType, Ob case .keywords: // Keywords is handled differently to other settings updateKeywords(isChecked: isChecked) - case .oneToOneRoom: + case .oneToOneRoom, .allOtherMessages: updatePushAction( id: ruleID, enabled: enabled, standardActions: standardActions, - then: [.oneToOnePollStart, .msc3930oneToOnePollStart, .oneToOnePollEnd, .msc3930oneToOnePollEnd] - ) - - case .allOtherMessages: - updatePushAction( - id: ruleID, - enabled: enabled, - standardActions: standardActions, - then: [.pollStart, .msc3930pollStart, .pollEnd, .msc3930pollEnd] + then: ruleID.syncedRules ) default: @@ -212,8 +204,12 @@ private extension NotificationSettingsViewModel { func rulesUpdated(newRules: [NotificationPushRuleType]) { for rule in newRules { - guard let ruleId = NotificationPushRuleId(rawValue: rule.ruleId), - ruleIds.contains(ruleId) else { continue } + guard + let ruleId = NotificationPushRuleId(rawValue: rule.ruleId), + ruleIds.contains(ruleId) + else { + continue + } viewState.selectionState[ruleId] = isChecked(rule: rule) } }