mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Display the list of rooms with user-defined notification settings (#1535)
This commit is contained in:
+9
-5
@@ -19,6 +19,7 @@ import SwiftUI
|
||||
|
||||
struct NotificationSettingsScreenCoordinatorParameters {
|
||||
weak var navigationStackCoordinator: NavigationStackCoordinator?
|
||||
let userSession: UserSessionProtocol
|
||||
let userNotificationCenter: UserNotificationCenterProtocol
|
||||
let notificationSettings: NotificationSettingsProxyProtocol
|
||||
let isModallyPresented: Bool
|
||||
@@ -45,7 +46,8 @@ final class NotificationSettingsScreenCoordinator: CoordinatorProtocol {
|
||||
init(parameters: NotificationSettingsScreenCoordinatorParameters) {
|
||||
self.parameters = parameters
|
||||
|
||||
viewModel = NotificationSettingsScreenViewModel(appSettings: ServiceLocator.shared.settings,
|
||||
viewModel = NotificationSettingsScreenViewModel(userSession: parameters.userSession,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
userNotificationCenter: parameters.userNotificationCenter,
|
||||
notificationSettingsProxy: parameters.notificationSettings,
|
||||
isModallyPresented: parameters.isModallyPresented)
|
||||
@@ -59,8 +61,8 @@ final class NotificationSettingsScreenCoordinator: CoordinatorProtocol {
|
||||
switch action {
|
||||
case .close:
|
||||
self.actionsSubject.send(.close)
|
||||
case .editDefaultMode(let isDirect):
|
||||
self.presentEditScreen(isDirect: isDirect)
|
||||
case .editDefaultMode(let chatType):
|
||||
self.presentEditScreen(chatType: chatType)
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
@@ -72,8 +74,10 @@ final class NotificationSettingsScreenCoordinator: CoordinatorProtocol {
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func presentEditScreen(isDirect: Bool) {
|
||||
let editSettingsParameters = NotificationSettingsEditScreenCoordinatorParameters(isDirect: isDirect,
|
||||
private func presentEditScreen(chatType: NotificationSettingsChatType) {
|
||||
let editSettingsParameters = NotificationSettingsEditScreenCoordinatorParameters(navigationStackCoordinator: parameters.navigationStackCoordinator,
|
||||
chatType: chatType,
|
||||
userSession: parameters.userSession,
|
||||
notificationSettings: parameters.notificationSettings)
|
||||
let editSettingsCoordinator = NotificationSettingsEditScreenCoordinator(parameters: editSettingsParameters)
|
||||
navigationStackCoordinator?.push(editSettingsCoordinator)
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ import UIKit
|
||||
|
||||
enum NotificationSettingsScreenViewModelAction {
|
||||
case close
|
||||
case editDefaultMode(isDirect: Bool)
|
||||
case editDefaultMode(chatType: NotificationSettingsChatType)
|
||||
}
|
||||
|
||||
struct NotificationSettingsScreenViewState: BindableState {
|
||||
|
||||
+5
-3
@@ -24,13 +24,15 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy
|
||||
private let appSettings: AppSettings
|
||||
private let userNotificationCenter: UserNotificationCenterProtocol
|
||||
private let notificationSettingsProxy: NotificationSettingsProxyProtocol
|
||||
private let userSession: UserSessionProtocol
|
||||
@CancellableTask private var fetchSettingsTask: Task<Void, Error>?
|
||||
|
||||
var actions: AnyPublisher<NotificationSettingsScreenViewModelAction, Never> {
|
||||
actionsSubject.eraseToAnyPublisher()
|
||||
}
|
||||
|
||||
init(appSettings: AppSettings, userNotificationCenter: UserNotificationCenterProtocol, notificationSettingsProxy: NotificationSettingsProxyProtocol, isModallyPresented: Bool) {
|
||||
init(userSession: UserSessionProtocol, appSettings: AppSettings, userNotificationCenter: UserNotificationCenterProtocol, notificationSettingsProxy: NotificationSettingsProxyProtocol, isModallyPresented: Bool) {
|
||||
self.userSession = userSession
|
||||
self.appSettings = appSettings
|
||||
self.userNotificationCenter = userNotificationCenter
|
||||
self.notificationSettingsProxy = notificationSettingsProxy
|
||||
@@ -60,9 +62,9 @@ class NotificationSettingsScreenViewModel: NotificationSettingsScreenViewModelTy
|
||||
case .changedEnableNotifications:
|
||||
toggleNotifications()
|
||||
case .groupChatsTapped:
|
||||
actionsSubject.send(.editDefaultMode(isDirect: false))
|
||||
actionsSubject.send(.editDefaultMode(chatType: .groupChat))
|
||||
case .directChatsTapped:
|
||||
actionsSubject.send(.editDefaultMode(isDirect: true))
|
||||
actionsSubject.send(.editDefaultMode(chatType: .oneToOneChat))
|
||||
case .roomMentionChanged:
|
||||
guard let settings = state.settings, settings.roomMentionsEnabled != state.bindings.roomMentionsEnabled else {
|
||||
return
|
||||
|
||||
+4
-1
@@ -173,7 +173,10 @@ struct NotificationSettingsScreen_Previews: PreviewProvider {
|
||||
notificationSettingsProxy.isRoomMentionEnabledReturnValue = true
|
||||
notificationSettingsProxy.isCallEnabledReturnValue = false
|
||||
|
||||
var viewModel = NotificationSettingsScreenViewModel(appSettings: appSettings,
|
||||
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: "John Doe"), mediaProvider: MockMediaProvider())
|
||||
|
||||
var viewModel = NotificationSettingsScreenViewModel(userSession: userSession,
|
||||
appSettings: appSettings,
|
||||
userNotificationCenter: notificationCenter,
|
||||
notificationSettingsProxy: notificationSettingsProxy,
|
||||
isModallyPresented: true)
|
||||
|
||||
Reference in New Issue
Block a user