mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Update files following swiftformat upgrade
This commit is contained in:
committed by
Stefan Ceriu
parent
fe189fcfed
commit
23062901c0
@@ -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