mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 08:15:24 +00:00
Add @MainActor to some of the hook points.
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
import Compound
|
||||
|
||||
protocol CompoundHookProtocol {
|
||||
func override(colors: CompoundColors, uiColors: CompoundUIColors)
|
||||
@MainActor func override(colors: CompoundColors, uiColors: CompoundUIColors)
|
||||
}
|
||||
|
||||
struct DefaultCompoundHook: CompoundHookProtocol {
|
||||
|
||||
@@ -15,11 +15,11 @@ enum RemoteSettingsError: Error {
|
||||
|
||||
protocol RemoteSettingsHookProtocol {
|
||||
#if IS_MAIN_APP
|
||||
func initializeCache(using client: ClientProtocol, applyingTo appSettings: CommonSettingsProtocol) async -> Result<Void, RemoteSettingsError>
|
||||
@MainActor func initializeCache(using client: ClientProtocol, applyingTo appSettings: CommonSettingsProtocol) async -> Result<Void, RemoteSettingsError>
|
||||
func updateCache(using client: ClientProtocol) async
|
||||
func reset(_ appSettings: CommonSettingsProtocol)
|
||||
@MainActor func reset(_ appSettings: CommonSettingsProtocol)
|
||||
#endif
|
||||
func loadCache(forHomeserver homeserver: String, applyingTo appSettings: CommonSettingsProtocol)
|
||||
@MainActor func loadCache(forHomeserver homeserver: String, applyingTo appSettings: CommonSettingsProtocol)
|
||||
}
|
||||
|
||||
struct DefaultRemoteSettingsHook: RemoteSettingsHookProtocol {
|
||||
|
||||
@@ -113,7 +113,7 @@ class UserSessionStore: UserSessionStoreProtocol {
|
||||
}
|
||||
|
||||
let homeserverURL = credentials.restorationToken.session.homeserverUrl
|
||||
appHooks.remoteSettingsHook.loadCache(forHomeserver: homeserverURL, applyingTo: appSettings)
|
||||
await appHooks.remoteSettingsHook.loadCache(forHomeserver: homeserverURL, applyingTo: appSettings)
|
||||
|
||||
let builder = ClientBuilder
|
||||
.baseBuilder(httpProxy: URL(string: homeserverURL)?.globalProxy,
|
||||
|
||||
@@ -62,8 +62,11 @@ class NotificationServiceExtension: UNNotificationServiceExtension {
|
||||
super.init()
|
||||
}
|
||||
|
||||
override func didReceive(_ request: UNNotificationRequest,
|
||||
withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
|
||||
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
|
||||
Task { await handle(request, withContentHandler: contentHandler) }
|
||||
}
|
||||
|
||||
private func handle(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) async {
|
||||
guard !DataProtectionManager.isDeviceLockedAfterReboot(containerURL: URL.appGroupContainerDirectory),
|
||||
let roomID = request.content.roomID,
|
||||
let eventID = request.content.eventID,
|
||||
@@ -78,7 +81,7 @@ class NotificationServiceExtension: UNNotificationServiceExtension {
|
||||
}
|
||||
|
||||
let homeserverURL = credentials.restorationToken.session.homeserverUrl
|
||||
appHooks.remoteSettingsHook.loadCache(forHomeserver: homeserverURL, applyingTo: settings)
|
||||
await appHooks.remoteSettingsHook.loadCache(forHomeserver: homeserverURL, applyingTo: settings)
|
||||
|
||||
guard let mutableContent = request.content.mutableCopy() as? UNMutableNotificationContent else {
|
||||
return contentHandler(request.content)
|
||||
@@ -90,27 +93,25 @@ class NotificationServiceExtension: UNNotificationServiceExtension {
|
||||
|
||||
MXLog.info("\(tag) Received payload: \(request.content.userInfo)")
|
||||
|
||||
Task {
|
||||
do {
|
||||
let userSession = try await NSEUserSession(credentials: credentials,
|
||||
roomID: roomID,
|
||||
clientSessionDelegate: keychainController,
|
||||
appHooks: appHooks,
|
||||
appSettings: settings)
|
||||
|
||||
notificationHandler = NotificationHandler(userSession: userSession,
|
||||
settings: settings,
|
||||
contentHandler: contentHandler,
|
||||
notificationContent: mutableContent,
|
||||
tag: tag)
|
||||
|
||||
ExtensionLogger.logMemory(with: tag)
|
||||
MXLog.info("\(tag) Configured user session")
|
||||
|
||||
await notificationHandler?.processEvent(eventID, roomID: roomID)
|
||||
} catch {
|
||||
MXLog.error("Failed creating user session with error: \(error)")
|
||||
}
|
||||
do {
|
||||
let userSession = try await NSEUserSession(credentials: credentials,
|
||||
roomID: roomID,
|
||||
clientSessionDelegate: keychainController,
|
||||
appHooks: appHooks,
|
||||
appSettings: settings)
|
||||
|
||||
notificationHandler = NotificationHandler(userSession: userSession,
|
||||
settings: settings,
|
||||
contentHandler: contentHandler,
|
||||
notificationContent: mutableContent,
|
||||
tag: tag)
|
||||
|
||||
ExtensionLogger.logMemory(with: tag)
|
||||
MXLog.info("\(tag) Configured user session")
|
||||
|
||||
await notificationHandler?.processEvent(eventID, roomID: roomID)
|
||||
} catch {
|
||||
MXLog.error("Failed creating user session with error: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/element-hq/compound-design-tokens",
|
||||
"state" : {
|
||||
"revision" : "be5d26dfd4ad659b0d3b3aec1ad1cccd0dc8d063",
|
||||
"version" : "6.0.0"
|
||||
"revision" : "93b48b3c88473562fb42c34100e45df25a4aea97",
|
||||
"version" : "6.3.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -40,7 +40,7 @@ public class CompoundColors {
|
||||
|
||||
/// Customise the colour at the specified key path with the supplied colour.
|
||||
/// Supplying `nil` as the colour will remove any existing customisation.
|
||||
public func override(_ keyPath: KeyPath<CompoundColorTokens, Color>, with color: Color?) {
|
||||
@MainActor public func override(_ keyPath: KeyPath<CompoundColorTokens, Color>, with color: Color?) {
|
||||
overrides[keyPath] = color
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public class CompoundUIColors {
|
||||
|
||||
/// Customise the colour at the specified key path with the supplied colour.
|
||||
/// Supplying `nil` as the colour will remove any existing customisation.
|
||||
public func override(_ keyPath: KeyPath<CompoundUIColorTokens, UIColor>, with color: UIColor?) {
|
||||
@MainActor public func override(_ keyPath: KeyPath<CompoundUIColorTokens, UIColor>, with color: UIColor?) {
|
||||
overrides[keyPath] = color
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import Foundation
|
||||
@testable import Compound
|
||||
import XCTest
|
||||
|
||||
@MainActor
|
||||
class OverrideColorTests: XCTestCase {
|
||||
func testSwiftUI() {
|
||||
let colors = CompoundColors()
|
||||
|
||||
Reference in New Issue
Block a user