mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Move any visible account settings into AccountSettings. (#6308)
* Remove the now unused setting to disable in-app notifications. * Move visible account settings into AccountSettings. Have ignored enableNotifications for now as that will require reworking the NotificationManager. * Allow different sounds to be selected for each account. * Move defaultNotificationTone into AccountSettings.
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
//
|
||||
// Copyright 2026 Element Creations Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import UserNotifications
|
||||
|
||||
nonisolated extension AppSettings {
|
||||
/// The sound name to use in outgoing notifications.
|
||||
/// Falls back to the default Element X tone if no custom tone has been selected.
|
||||
var notificationSoundName: UNNotificationSoundName {
|
||||
if selectedNotificationTone == nil {
|
||||
return UNNotificationSoundName("message.caf")
|
||||
} else {
|
||||
return UNNotificationSoundName(NotificationToneManager.selectedToneFilename)
|
||||
}
|
||||
}
|
||||
|
||||
/// A `UNNotificationSound` built from `notificationSoundName`, ready to attach to a notification content object.
|
||||
var notificationSound: UNNotificationSound {
|
||||
UNNotificationSound(named: notificationSoundName)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// Copyright 2026 Element Creations Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import UserNotifications
|
||||
|
||||
nonisolated extension AccountSettings {
|
||||
/// The sound to attach to outgoing notifications, falling back to the default tone if no tone has been selected.
|
||||
var notificationSound: UNNotificationSound {
|
||||
(selectedNotificationTone ?? defaultNotificationTone.publisher.value).notificationSound
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// Copyright 2026 Element Creations Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import UserNotifications
|
||||
|
||||
nonisolated extension NotificationTone {
|
||||
/// A `UNNotificationSound` for this tone, ready to attach to a notification content object.
|
||||
var notificationSound: UNNotificationSound {
|
||||
UNNotificationSound(named: UNNotificationSoundName(NotificationToneManager.soundName(for: self)))
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import MatrixRustSDK
|
||||
|
||||
// sourcery: AutoMockable
|
||||
nonisolated protocol NSEUserSessionProtocol {
|
||||
var userSettings: UserSettings { get }
|
||||
var inviteAvatarsVisibility: InviteAvatars { get async }
|
||||
var mediaPreviewVisibility: MediaPreviews { get async }
|
||||
var threadsEnabled: Bool { get }
|
||||
@@ -59,7 +60,8 @@ final nonisolated class NSEUserSession: NSEUserSessionProtocol {
|
||||
appSettings: AppSettings,
|
||||
appHooks: AppHooks) async throws {
|
||||
userID = credentials.userID
|
||||
userSettings = appSettings.userSettings(for: credentials.userID)
|
||||
userSettings = appHooks.userSessionHook.configure(appSettings.userSettings(for: credentials.userID),
|
||||
forHomeserver: credentials.restorationToken.session.homeserverUrl)
|
||||
|
||||
baseClient = try await clientFactory.makeNSEClient(credentials: credentials,
|
||||
roomID: roomID,
|
||||
|
||||
@@ -15,7 +15,6 @@ import Version
|
||||
|
||||
nonisolated struct NotificationContentBuilder {
|
||||
let messageEventStringBuilder: RoomMessageEventStringBuilder
|
||||
let notificationSoundName: UNNotificationSoundName
|
||||
let userSession: NSEUserSessionProtocol
|
||||
|
||||
/// Process the given notification item proxy
|
||||
@@ -50,7 +49,7 @@ nonisolated struct NotificationContentBuilder {
|
||||
notificationContent.threadIdentifier = threadIdentifier.replacingOccurrences(of: "@", with: "")
|
||||
|
||||
MXLog.info("isNoisy: \(notificationItem.isNoisy)")
|
||||
notificationContent.sound = notificationItem.isNoisy ? .init(named: notificationSoundName) : nil
|
||||
notificationContent.sound = notificationItem.isNoisy ? userSession.userSettings.account.notificationSound : nil
|
||||
|
||||
switch notificationItem.event {
|
||||
case .none:
|
||||
|
||||
@@ -39,7 +39,6 @@ nonisolated class NotificationHandler {
|
||||
style: .plain)
|
||||
|
||||
notificationContentBuilder = NotificationContentBuilder(messageEventStringBuilder: eventStringBuilder,
|
||||
notificationSoundName: userSession.userSettings.app.notificationSoundName,
|
||||
userSession: userSession)
|
||||
}
|
||||
|
||||
|
||||
@@ -257,7 +257,7 @@ actor NotificationServiceExtensionActor {
|
||||
|
||||
let content = UNMutableNotificationContent()
|
||||
content.body = L10n.notificationReceivedWhileOfflineIos
|
||||
content.sound = appSettings.notificationSound
|
||||
content.sound = NotificationTone.default.notificationSound // Use the default sound as missed notifications could be for any account.
|
||||
|
||||
let request = UNNotificationRequest(identifier: Self.receivedWhileOfflineNotificationID, content: content, trigger: nil)
|
||||
UNUserNotificationCenter.current().add(request)
|
||||
|
||||
@@ -89,6 +89,7 @@ targets:
|
||||
- path: ../../ElementX/Sources/AppHooks/Hooks/TracingHook.swift
|
||||
- path: ../../ElementX/Sources/AppHooks/Hooks/ClientFactoryHook.swift
|
||||
- path: ../../ElementX/Sources/AppHooks/Hooks/RemoteSettingsHook.swift
|
||||
- path: ../../ElementX/Sources/AppHooks/Hooks/UserSessionHook.swift
|
||||
- path: ../../Components/Secrets/Secrets.swift
|
||||
- path: ../../ElementX/Sources/Application/Settings
|
||||
- path: ../../ElementX/Sources/Application/TargetConfiguration.swift
|
||||
|
||||
Reference in New Issue
Block a user