mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Swift 6 migration for NSE (#5608)
* swift 6 support for NSE and concurrency safe implementations for it * enforcing required Sendable conformance for swift 6 migration in NSE * use Mutex to access the string builder cache * use an async stream to update timeline items diffs * fix for Sendable appHooks
This commit is contained in:
@@ -7,66 +7,107 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Synchronization
|
||||
|
||||
class AppHooks: AppHooksProtocol {
|
||||
final class AppHooks: AppHooksProtocol {
|
||||
#if IS_MAIN_APP
|
||||
func configure(with userSession: UserSessionProtocol?) async {
|
||||
await roomScreenHook.configure(with: userSession)
|
||||
}
|
||||
|
||||
private(set) var appSettingsHook: AppSettingsHookProtocol = DefaultAppSettingsHook()
|
||||
private let _appSettingsHook: Mutex<AppSettingsHookProtocol> = Mutex(DefaultAppSettingsHook())
|
||||
var appSettingsHook: AppSettingsHookProtocol {
|
||||
_appSettingsHook.withLock { $0 }
|
||||
}
|
||||
|
||||
func registerAppSettingsHook(_ hook: AppSettingsHookProtocol) {
|
||||
appSettingsHook = hook
|
||||
_appSettingsHook.withLock { $0 = hook }
|
||||
}
|
||||
|
||||
private(set) var compoundHook: CompoundHookProtocol = DefaultCompoundHook()
|
||||
private let _compoundHook: Mutex<CompoundHookProtocol> = Mutex(DefaultCompoundHook())
|
||||
var compoundHook: CompoundHookProtocol {
|
||||
_compoundHook.withLock { $0 }
|
||||
}
|
||||
|
||||
func registerCompoundHook(_ hook: CompoundHookProtocol) {
|
||||
compoundHook = hook
|
||||
_compoundHook.withLock { $0 = hook }
|
||||
}
|
||||
|
||||
private let _bugReportHook: Mutex<BugReportHookProtocol> = Mutex(DefaultBugReportHook())
|
||||
var bugReportHook: BugReportHookProtocol {
|
||||
_bugReportHook.withLock { $0 }
|
||||
}
|
||||
|
||||
private(set) var bugReportHook: BugReportHookProtocol = DefaultBugReportHook()
|
||||
func registerBugReportHook(_ hook: BugReportHookProtocol) {
|
||||
bugReportHook = hook
|
||||
_bugReportHook.withLock { $0 = hook }
|
||||
}
|
||||
|
||||
private let _certificateValidatorHook: Mutex<CertificateValidatorHookProtocol> = Mutex(DefaultCertificateValidator())
|
||||
var certificateValidatorHook: CertificateValidatorHookProtocol {
|
||||
_certificateValidatorHook.withLock { $0 }
|
||||
}
|
||||
|
||||
private(set) var certificateValidatorHook: CertificateValidatorHookProtocol = DefaultCertificateValidator()
|
||||
func registerCertificateValidatorHook(_ hook: CertificateValidatorHookProtocol) {
|
||||
certificateValidatorHook = hook
|
||||
_certificateValidatorHook.withLock { $0 = hook }
|
||||
}
|
||||
|
||||
private let _oAuthPresenterHook: Mutex<OAuthPresenterHookProtocol> = Mutex(DefaultOAuthPresenterHook())
|
||||
var oAuthPresenterHook: OAuthPresenterHookProtocol {
|
||||
_oAuthPresenterHook.withLock { $0 }
|
||||
}
|
||||
|
||||
private(set) var oAuthPresenterHook: OAuthPresenterHookProtocol = DefaultOAuthPresenterHook()
|
||||
func registerOAuthPresenterHook(_ hook: OAuthPresenterHookProtocol) {
|
||||
oAuthPresenterHook = hook
|
||||
_oAuthPresenterHook.withLock { $0 = hook }
|
||||
}
|
||||
|
||||
private let _roomScreenHook: Mutex<RoomScreenHookProtocol> = Mutex(DefaultRoomScreenHook())
|
||||
var roomScreenHook: RoomScreenHookProtocol {
|
||||
_roomScreenHook.withLock { $0 }
|
||||
}
|
||||
|
||||
private(set) var roomScreenHook: RoomScreenHookProtocol = DefaultRoomScreenHook()
|
||||
func registerRoomScreenHook(_ hook: RoomScreenHookProtocol) {
|
||||
roomScreenHook = hook
|
||||
_roomScreenHook.withLock { $0 = hook }
|
||||
}
|
||||
|
||||
private let _developerOptionsScreenHook: Mutex<DeveloperOptionsScreenHookProtocol> = Mutex(DefaultDeveloperOptionsScreenHook())
|
||||
var developerOptionsScreenHook: DeveloperOptionsScreenHookProtocol {
|
||||
_developerOptionsScreenHook.withLock { $0 }
|
||||
}
|
||||
|
||||
private(set) var developerOptionsScreenHook: DeveloperOptionsScreenHookProtocol = DefaultDeveloperOptionsScreenHook()
|
||||
func registerDeveloperOptionsScreenHook(_ hook: DeveloperOptionsScreenHookProtocol) {
|
||||
developerOptionsScreenHook = hook
|
||||
_developerOptionsScreenHook.withLock { $0 = hook }
|
||||
}
|
||||
#endif
|
||||
|
||||
private(set) var tracingHook: TracingHookProtocol = DefaultTracingHook()
|
||||
private let _tracingHook: Mutex<TracingHookProtocol> = Mutex(DefaultTracingHook())
|
||||
var tracingHook: TracingHookProtocol {
|
||||
_tracingHook.withLock { $0 }
|
||||
}
|
||||
|
||||
func registerTracingHook(_ hook: TracingHookProtocol) {
|
||||
tracingHook = hook
|
||||
_tracingHook.withLock { $0 = hook }
|
||||
}
|
||||
|
||||
private let _clientBuilderHook: Mutex<ClientBuilderHookProtocol> = Mutex(DefaultClientBuilderHook())
|
||||
var clientBuilderHook: ClientBuilderHookProtocol {
|
||||
_clientBuilderHook.withLock { $0 }
|
||||
}
|
||||
|
||||
private(set) var clientBuilderHook: ClientBuilderHookProtocol = DefaultClientBuilderHook()
|
||||
func registerClientBuilderHook(_ hook: ClientBuilderHookProtocol) {
|
||||
clientBuilderHook = hook
|
||||
_clientBuilderHook.withLock { $0 = hook }
|
||||
}
|
||||
|
||||
private let _remoteSettingsHook: Mutex<RemoteSettingsHookProtocol> = Mutex(DefaultRemoteSettingsHook())
|
||||
var remoteSettingsHook: RemoteSettingsHookProtocol {
|
||||
_remoteSettingsHook.withLock { $0 }
|
||||
}
|
||||
|
||||
private(set) var remoteSettingsHook: RemoteSettingsHookProtocol = DefaultRemoteSettingsHook()
|
||||
func registerRemoteSettingsHook(_ hook: RemoteSettingsHookProtocol) {
|
||||
remoteSettingsHook = hook
|
||||
_remoteSettingsHook.withLock { $0 = hook }
|
||||
}
|
||||
}
|
||||
|
||||
protocol AppHooksProtocol {
|
||||
protocol AppHooksProtocol: Sendable {
|
||||
func setUp()
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import MatrixRustSDK
|
||||
|
||||
protocol ClientBuilderHookProtocol {
|
||||
protocol ClientBuilderHookProtocol: Sendable {
|
||||
func configure(_ builder: ClientBuilder) -> ClientBuilder
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ enum RemoteSettingsError: Error {
|
||||
case elementProRequired(serverName: String)
|
||||
}
|
||||
|
||||
protocol RemoteSettingsHookProtocol {
|
||||
protocol RemoteSettingsHookProtocol: Sendable {
|
||||
#if IS_MAIN_APP
|
||||
@MainActor func initializeCache(using client: ClientProtocol, applyingTo appSettings: CommonSettingsProtocol) async -> Result<Void, RemoteSettingsError>
|
||||
func updateCache(using client: ClientProtocol) async
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
import MatrixRustSDK
|
||||
|
||||
protocol TracingHookProtocol {
|
||||
protocol TracingHookProtocol: Sendable {
|
||||
func update(_ configuration: TracingConfiguration, with rageshakeURL: RemotePreference<RageshakeConfiguration>)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user