Move complete room notification settings module to RiotSwiftUI and fix naming/directory structure.

This commit is contained in:
David Langley
2021-09-02 14:09:29 +01:00
parent bbf7d28928
commit 14169c6594
13 changed files with 19 additions and 19 deletions
@@ -1,57 +0,0 @@
//
// Copyright 2021 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Foundation
import Combine
/**
A service for changing notification settings and keywords
*/
@available(iOS 14.0, *)
protocol NotificationSettingsServiceType {
/**
Publisher of all push rules.
*/
var rulesPublisher: AnyPublisher<[NotificationPushRule], Never> { get }
/**
Publisher of content rules.
*/
var contentRulesPublisher: AnyPublisher<[NotificationPushRule], Never> { get }
/**
Adds a keyword.
- Parameters:
- keyword: The keyword to add.
- enabled: Whether the keyword should be added in the enabled or disabled state.
*/
func add(keyword: String, enabled: Bool)
/**
Removes a keyword.
- Parameters:
- keyword: The keyword to remove.
*/
func remove(keyword: String)
/**
Updates the push rule actions.
- Parameters:
- ruleId: The id of the rule.
- enabled: Whether the rule should be enabled or disabled.
- actions: The actions to update with.
*/
func updatePushRuleActions(for ruleId: String, enabled: Bool, actions: NotificationActions?)
}
@@ -155,7 +155,7 @@ final class NotificationSettingsViewModel: NotificationSettingsViewModelType, Ob
}
// MARK: - Private
private func rulesUpdated(newRules: [NotificationPushRule]) {
private func rulesUpdated(newRules: [NotificationPushRuleType]) {
for rule in newRules {
guard let ruleId = NotificationPushRuleId(rawValue: rule.ruleId),
ruleIds.contains(ruleId) else { continue }
@@ -174,7 +174,7 @@ final class NotificationSettingsViewModel: NotificationSettingsViewModelType, Ob
Matcing is done by comparing the rule against the static definitions for that rule.
The same logic is used on android.
*/
private func isChecked(rule: NotificationPushRule) -> Bool {
private func isChecked(rule: NotificationPushRuleType) -> Bool {
guard let ruleId = NotificationPushRuleId(rawValue: rule.ruleId) else { return false }
let firstIndex = NotificationIndex.allCases.first { nextIndex in