mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Update files following swiftformat upgrade
This commit is contained in:
committed by
Stefan Ceriu
parent
fe189fcfed
commit
23062901c0
@@ -198,18 +198,16 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
}
|
||||
|
||||
func toPresentable() -> AnyView {
|
||||
AnyView(
|
||||
navigationRootCoordinator.toPresentable()
|
||||
.environment(\.analyticsService, ServiceLocator.shared.analytics)
|
||||
.onReceive(appSettings.$appAppearance) { [weak self] appAppearance in
|
||||
guard let self else { return }
|
||||
AnyView(navigationRootCoordinator.toPresentable()
|
||||
.environment(\.analyticsService, ServiceLocator.shared.analytics)
|
||||
.onReceive(appSettings.$appAppearance) { [weak self] appAppearance in
|
||||
guard let self else { return }
|
||||
|
||||
windowManager.windows.forEach { window in
|
||||
// Unfortunately .preferredColorScheme doesn't propagate properly throughout the app when changed
|
||||
window.overrideUserInterfaceStyle = appAppearance.interfaceStyle
|
||||
}
|
||||
windowManager.windows.forEach { window in
|
||||
// Unfortunately .preferredColorScheme doesn't propagate properly throughout the app when changed
|
||||
window.overrideUserInterfaceStyle = appAppearance.interfaceStyle
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
func handlePotentialPhishingAttempt(url: URL, openURLAction: @escaping (URL) -> Void) -> Bool {
|
||||
@@ -450,7 +448,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
userSessionMigrationsOldVersion = nil
|
||||
}
|
||||
|
||||
// This could be removed once the adoption of 25.06.x is widespread.
|
||||
/// This could be removed once the adoption of 25.06.x is widespread.
|
||||
private func performSettingsToAccountDataMigration(userSession: UserSessionProtocol) {
|
||||
guard let userDefaults = UserDefaults(suiteName: InfoPlistReader.main.appGroupIdentifier) else {
|
||||
return
|
||||
@@ -1200,12 +1198,12 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
// This is important for the app to keep refreshing in the background
|
||||
scheduleBackgroundAppRefresh()
|
||||
|
||||
/// We have a lot of crashes stemming here which we previously believed are caused by stopSync not being async
|
||||
/// on the client proxy side (see the comment on that method). We have now realised that will likely not fix anything but
|
||||
/// we also noticed this does not crash on the main thread, even though the whole AppCoordinator is on the Main actor.
|
||||
/// As such, we introduced a MainActor conformance on the expirationHandler but we are also assuming main actor
|
||||
/// isolated in the `stopSync` method above.
|
||||
/// https://sentry.tools.element.io/organizations/element/issues/4477794/
|
||||
// We have a lot of crashes stemming here which we previously believed are caused by stopSync not being async
|
||||
// on the client proxy side (see the comment on that method). We have now realised that will likely not fix anything but
|
||||
// we also noticed this does not crash on the main thread, even though the whole AppCoordinator is on the Main actor.
|
||||
// As such, we introduced a MainActor conformance on the expirationHandler but we are also assuming main actor
|
||||
// isolated in the `stopSync` method above.
|
||||
// https://sentry.tools.element.io/organizations/element/issues/4477794/
|
||||
task.expirationHandler = { @Sendable [weak self] in
|
||||
MXLog.info("Background app refresh task is about to expire.")
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class AppMediator: AppMediatorProtocol {
|
||||
self.networkMonitor = networkMonitor
|
||||
}
|
||||
|
||||
// UIApplication.State won't update if we store this e.g. in the constructor
|
||||
/// UIApplication.State won't update if we store this e.g. in the constructor
|
||||
private var application: UIApplication {
|
||||
UIApplication.shared
|
||||
}
|
||||
|
||||
@@ -41,6 +41,11 @@ struct CommonFlowParameters {
|
||||
let notificationManager: NotificationManagerProtocol
|
||||
let stateMachineFactory: StateMachineFactoryProtocol
|
||||
|
||||
var windowManager: WindowManagerProtocol { appMediator.windowManager }
|
||||
var ongoingCallRoomIDPublisher: CurrentValuePublisher<String?, Never> { elementCallService.ongoingCallRoomIDPublisher }
|
||||
var windowManager: WindowManagerProtocol {
|
||||
appMediator.windowManager
|
||||
}
|
||||
|
||||
var ongoingCallRoomIDPublisher: CurrentValuePublisher<String?, Never> {
|
||||
elementCallService.ongoingCallRoomIDPublisher
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,8 +57,13 @@ import SwiftUI
|
||||
let module: NavigationModule
|
||||
let details: TabDetails
|
||||
|
||||
var id: ObjectIdentifier { module.id }
|
||||
@MainActor var coordinator: CoordinatorProtocol? { module.coordinator }
|
||||
var id: ObjectIdentifier {
|
||||
module.id
|
||||
}
|
||||
|
||||
@MainActor var coordinator: CoordinatorProtocol? {
|
||||
module.coordinator
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate var tabModules = [TabModule]() {
|
||||
|
||||
@@ -13,7 +13,7 @@ import EmbeddedElementCall
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
// Common settings between app and NSE
|
||||
/// Common settings between app and NSE
|
||||
protocol CommonSettingsProtocol {
|
||||
var logLevel: LogLevel { get }
|
||||
var traceLogPacks: Set<TraceLogPack> { get }
|
||||
@@ -265,7 +265,9 @@ final class AppSettings {
|
||||
}
|
||||
|
||||
private(set) var pushGatewayBaseURL: URL = "https://matrix.org"
|
||||
var pushGatewayNotifyEndpoint: URL { pushGatewayBaseURL.appending(path: "_matrix/push/v1/notify") }
|
||||
var pushGatewayNotifyEndpoint: URL {
|
||||
pushGatewayBaseURL.appending(path: "_matrix/push/v1/notify")
|
||||
}
|
||||
|
||||
@UserPreference(key: UserDefaultsKeys.enableNotifications, defaultValue: true, storageType: .userDefaults(store))
|
||||
var enableNotifications
|
||||
@@ -305,7 +307,9 @@ final class AppSettings {
|
||||
/// The URL to open with more information about analytics terms. When this is `nil` the "Learn more" link will be hidden.
|
||||
private(set) var analyticsTermsURL: URL? = "https://element.io/cookie-policy"
|
||||
/// Whether or not there the app is able ask for user consent to enable analytics or sentry reporting.
|
||||
var canPromptForAnalytics: Bool { analyticsConfiguration != nil || bugReportSentryURL != nil }
|
||||
var canPromptForAnalytics: Bool {
|
||||
analyticsConfiguration != nil || bugReportSentryURL != nil
|
||||
}
|
||||
|
||||
private static func makeAnalyticsConfiguration() -> AnalyticsConfiguration? {
|
||||
guard let host = Secrets.postHogHost, let apiKey = Secrets.postHogAPIKey else { return nil }
|
||||
@@ -364,7 +368,7 @@ final class AppSettings {
|
||||
|
||||
// MARK: - Maps
|
||||
|
||||
// maptiler base url
|
||||
/// maptiler base url
|
||||
private(set) var mapTilerConfiguration = MapTilerConfiguration(baseURL: "https://api.maptiler.com/maps",
|
||||
apiKey: Secrets.mapLibreAPIKey,
|
||||
lightStyleID: "9bc819c8-e627-474a-a348-ec144fe3d810",
|
||||
@@ -377,14 +381,14 @@ final class AppSettings {
|
||||
|
||||
// MARK: - Feature Flags
|
||||
|
||||
// Spaces
|
||||
/// Spaces
|
||||
@UserPreference(key: UserDefaultsKeys.spaceSettingsEnabled, defaultValue: false, storageType: .userDefaults(store))
|
||||
var spaceSettingsEnabled
|
||||
|
||||
@UserPreference(key: UserDefaultsKeys.createSpaceEnabled, defaultValue: false, storageType: .userDefaults(store))
|
||||
var createSpaceEnabled
|
||||
|
||||
// Others
|
||||
/// Others
|
||||
@UserPreference(key: UserDefaultsKeys.publicSearchEnabled, defaultValue: false, storageType: .userDefaults(store))
|
||||
var publicSearchEnabled
|
||||
|
||||
|
||||
@@ -22,5 +22,7 @@ struct MapTilerConfiguration {
|
||||
/// A MapLibre style ID for a dark-mode map.
|
||||
let darkStyleID: String
|
||||
|
||||
var isEnabled: Bool { apiKey != nil }
|
||||
var isEnabled: Bool {
|
||||
apiKey != nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,13 @@ import Combine
|
||||
class RemotePreference<T: Equatable> {
|
||||
private let defaultValue: T
|
||||
private let subject: CurrentValueSubject<T, Never>
|
||||
var publisher: CurrentValuePublisher<T, Never> { subject.asCurrentValuePublisher() }
|
||||
var isRemotelyConfigured: Bool { subject.value != defaultValue }
|
||||
var publisher: CurrentValuePublisher<T, Never> {
|
||||
subject.asCurrentValuePublisher()
|
||||
}
|
||||
|
||||
var isRemotelyConfigured: Bool {
|
||||
subject.value != defaultValue
|
||||
}
|
||||
|
||||
init(_ defaultValue: T) {
|
||||
self.defaultValue = defaultValue
|
||||
|
||||
@@ -24,14 +24,17 @@ final class UserPreference<T: Codable> {
|
||||
}
|
||||
|
||||
private let key: String
|
||||
private var remoteKey: String { "\(Self.remotePrefix)\(key)" }
|
||||
private var remoteKey: String {
|
||||
"\(Self.remotePrefix)\(key)"
|
||||
}
|
||||
|
||||
private var keyedStorage: any KeyedStorage<T>
|
||||
private let defaultValue: T
|
||||
private let subject: PassthroughSubject<T, Never> = .init()
|
||||
private let mode: Mode
|
||||
|
||||
// This can be used to check if is still possible for the user to change the value or not
|
||||
// Can only be accessed by using `_preferenceName.isLockedToRemote`
|
||||
/// This can be used to check if is still possible for the user to change the value or not
|
||||
/// Can only be accessed by using `_preferenceName.isLockedToRemote`
|
||||
var isLockedToRemote: Bool {
|
||||
mode == .remoteOverLocal && remoteValue != nil
|
||||
}
|
||||
@@ -53,7 +56,7 @@ final class UserPreference<T: Codable> {
|
||||
self.mode = mode
|
||||
}
|
||||
|
||||
// The wrapped value is supposed to be the one updated by the user so it can only control the local value
|
||||
/// The wrapped value is supposed to be the one updated by the user so it can only control the local value
|
||||
var wrappedValue: T {
|
||||
get {
|
||||
switch mode {
|
||||
@@ -69,8 +72,8 @@ final class UserPreference<T: Codable> {
|
||||
}
|
||||
}
|
||||
|
||||
// This is supposed to be the value that is set by the remote settings
|
||||
// So it can only be accessed by doing `AppSettings._preferenceName.remoteValue`
|
||||
/// This is supposed to be the value that is set by the remote settings
|
||||
/// So it can only be accessed by doing `AppSettings._preferenceName.remoteValue`
|
||||
var remoteValue: T? {
|
||||
get {
|
||||
keyedStorage[remoteKey]
|
||||
|
||||
Reference in New Issue
Block a user