mirror of
https://github.com/vector-im/element-ios.git
synced 2024-09-29 07:42:40 +00:00
Cleanup
This commit is contained in:
parent
989a4632cb
commit
dc41b2d52b
2 changed files with 19 additions and 12 deletions
|
@ -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 []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue