This commit is contained in:
Alfonso Grillo 2023-01-30 12:32:57 +01:00
parent 989a4632cb
commit dc41b2d52b
2 changed files with 19 additions and 12 deletions

View file

@ -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 []
}
}
}

View file

@ -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)
}
}