mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:06:00 +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:
@@ -467,10 +467,28 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
MXLog.info("Migrating to version 25.07.4, log files have been moved.")
|
||||
}
|
||||
|
||||
if oldVersion < Version(26, 10, 2) {
|
||||
MXLog.info("Migrating to version 26.10.2, moving notification sounds.")
|
||||
let soundsDirectory = URL.libraryDirectory.appending(component: "Sounds", directoryHint: .isDirectory)
|
||||
|
||||
// Sounds are now referenced directly, the duplicate file can go.
|
||||
try? FileManager.default.removeItem(at: soundsDirectory.appending(component: "currentAlert.caf"))
|
||||
|
||||
let oldCustomTonesLocation = soundsDirectory.appending(component: "AvailableSounds", directoryHint: .isDirectory)
|
||||
if FileManager.default.fileExists(atPath: oldCustomTonesLocation.path(percentEncoded: false)) {
|
||||
do {
|
||||
try FileManager.default.moveItem(at: oldCustomTonesLocation, to: URL.customTonesDirectory)
|
||||
} catch {
|
||||
MXLog.error("Failed moving custom notification sounds: \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Store the old version to run additional migrations on the user session once it has been set up.
|
||||
userSessionMigrationsOldVersion = oldVersion
|
||||
}
|
||||
|
||||
// swiftlint:disable:next cyclomatic_complexity
|
||||
private func performUserSessionMigrations(_ userSession: UserSessionProtocol) async {
|
||||
guard let oldVersion = userSessionMigrationsOldVersion else { return }
|
||||
|
||||
@@ -515,6 +533,23 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
userSession.userSettings.account.migrateAppSettingsValue(\.searchBreadcrumbsKey)
|
||||
}
|
||||
|
||||
if oldVersion < Version(26, 10, 2) {
|
||||
MXLog.info("Migrating to version 26.10.2, moving visible account settings.")
|
||||
userSession.userSettings.account.migrateAppSettingsValue(\.showAllRoomListActivityKey)
|
||||
userSession.userSettings.account.migrateAppSettingsValue(\.selectedNotificationToneKey)
|
||||
userSession.userSettings.account.migrateAppSettingsValue(\.sharePresenceKey)
|
||||
|
||||
// Make sure system notification sounds are available in the new directory.
|
||||
if let selectedNotificationTone = userSession.userSettings.account.selectedNotificationTone {
|
||||
do {
|
||||
MXLog.info("Copying the selected system notification sound.")
|
||||
try NotificationToneManager.copySystemToneIfNeeded(selectedNotificationTone)
|
||||
} catch {
|
||||
MXLog.error("Failed migrating the selected notification sound: \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
userSessionMigrationsOldVersion = nil
|
||||
}
|
||||
|
||||
|
||||
@@ -14,23 +14,34 @@ final nonisolated class AccountSettings: @unchecked Sendable {
|
||||
private let store: AccountUserDefaults
|
||||
private let userID: String
|
||||
|
||||
// MARK: Accounts
|
||||
// MARK: Session Activity
|
||||
|
||||
/// When this account was last selected, used to order the accounts most recently selected first.
|
||||
@UserPreference
|
||||
var lastSelectedDate: Date?
|
||||
|
||||
// MARK: Session
|
||||
|
||||
@UserPreference(defaultValue: false)
|
||||
var hasRunIdentityConfirmationOnboarding: Bool
|
||||
|
||||
// MARK: Search
|
||||
|
||||
/// The queries the user searched for and the rooms they opened from the results, most recent first.
|
||||
@UserPreference(defaultValue: [SearchBreadcrumb]())
|
||||
var searchBreadcrumbs: [SearchBreadcrumb]
|
||||
|
||||
// MARK: Visible Preferences
|
||||
|
||||
@UserPreference(defaultValue: true)
|
||||
var showAllRoomListActivity: Bool
|
||||
|
||||
/// The tone played when the user hasn't selected one, which the homeserver can configure remotely.
|
||||
let defaultNotificationTone: RemotePreference<NotificationTone> = .init(.default)
|
||||
|
||||
/// The sound played when delivering noisy notifications. If nil, use ``defaultNotificationTone``.
|
||||
@UserPreference
|
||||
var selectedNotificationTone: NotificationTone?
|
||||
|
||||
@UserPreference(defaultValue: true)
|
||||
var sharePresence: Bool
|
||||
|
||||
init(userID: String, store: UserDefaultsProtocol) {
|
||||
self.store = .init(userID: userID, store: store)
|
||||
self.userID = userID
|
||||
|
||||
@@ -235,9 +235,6 @@ final nonisolated class AppSettings: @unchecked Sendable {
|
||||
@UserPreference(defaultValue: true)
|
||||
var enableNotifications: Bool
|
||||
|
||||
@UserPreference(defaultValue: true)
|
||||
var enableInAppNotifications: Bool
|
||||
|
||||
@UserPreference(defaultValue: false)
|
||||
var hideQuietNotificationAlerts: Bool
|
||||
|
||||
@@ -253,10 +250,6 @@ final nonisolated class AppSettings: @unchecked Sendable {
|
||||
@UserPreference(defaultValue: 0)
|
||||
var lastKnownBadgeCount: Int
|
||||
|
||||
/// The sound played when delivering noisy notifications. If nil, use the ElementX default
|
||||
@UserPreference
|
||||
var selectedNotificationTone: NotificationTone?
|
||||
|
||||
// MARK: - Logging
|
||||
|
||||
@UserPreference(defaultValue: LogLevel.info)
|
||||
@@ -331,11 +324,6 @@ final nonisolated class AppSettings: @unchecked Sendable {
|
||||
@UserPreference(defaultValue: false)
|
||||
var liveLocationDisclaimerDisplayed: Bool
|
||||
|
||||
// MARK: - Home Screen
|
||||
|
||||
@UserPreference(defaultValue: true)
|
||||
var showAllRoomListActivity: Bool
|
||||
|
||||
// MARK: - Room Screen
|
||||
|
||||
@UserPreference(defaultValue: AppBuildType.current == .debug)
|
||||
@@ -382,11 +370,6 @@ final nonisolated class AppSettings: @unchecked Sendable {
|
||||
/// The MapTiler configuration used to build map URLs, which defaults to the bundled one.
|
||||
private(set) var mapTilerConfiguration = RemotePreference(AppSettings.bundledMapTilerConfiguration)
|
||||
|
||||
// MARK: - Presence
|
||||
|
||||
@UserPreference(defaultValue: true)
|
||||
var sharePresence: Bool
|
||||
|
||||
// MARK: - Feature Flags
|
||||
|
||||
/// Others
|
||||
|
||||
Reference in New Issue
Block a user