Fix various small errors when running in the Swift 6 language mode (#4109)

* Fix various small errors when running in the Swift 6 language mode

* Make the `TargetConfiguration` run on the main actor.

* Fixed a comment

* Add a comment as to why we can't make the whole NSE a main actor.

* Fix the unit tests

* Fix `blankLinesAtStartOfScope` swiftformat error.
This commit is contained in:
Stefan Ceriu
2025-05-13 11:43:47 +03:00
committed by GitHub
parent 433b042038
commit 4c7791ab24
11 changed files with 47 additions and 45 deletions

View File

@@ -27,16 +27,18 @@ import UserNotifications
// called on the same instance of `NotificationService` as a previous
// notification.
private let settings: CommonSettingsProtocol = AppSettings()
private let keychainController = KeychainController(service: .sessions,
accessGroup: InfoPlistReader.main.keychainAccessGroupIdentifier)
class NotificationServiceExtension: UNNotificationServiceExtension {
private var notificationHandler: NotificationHandler?
private let appHooks = AppHooks()
private let settings: CommonSettingsProtocol = AppSettings()
private let keychainController = KeychainController(service: .sessions,
accessGroup: InfoPlistReader.main.keychainAccessGroupIdentifier)
// We can make the whole NSE a MainActor after https://github.com/swiftlang/swift-evolution/blob/main/proposals/0371-isolated-synchronous-deinit.md
// otherwise we wouldn't be able to log the tag in the deinit.
deinit {
ExtensionLogger.logMemory(with: tag)
MXLog.info("\(tag) deinit")
@@ -61,15 +63,15 @@ class NotificationServiceExtension: UNNotificationServiceExtension {
return contentHandler(request.content)
}
Target.nse.configure(logLevel: settings.logLevel, traceLogPacks: settings.traceLogPacks)
MXLog.info("\(tag) #########################################")
ExtensionLogger.logMemory(with: tag)
MXLog.info("\(tag) Received payload: \(request.content.userInfo)")
Task {
await Target.nse.configure(logLevel: settings.logLevel, traceLogPacks: settings.traceLogPacks)
MXLog.info("\(tag) #########################################")
ExtensionLogger.logMemory(with: tag)
MXLog.info("\(tag) Received payload: \(request.content.userInfo)")
do {
let userSession = try await NSEUserSession(credentials: credentials,
roomID: roomID,