Attach @MainActor where needed
Some methods were updating UI from non-main thread.
This commit is contained in:
parent
f33380b4e2
commit
58e375ec41
|
@ -27,6 +27,7 @@ import Foundation
|
|||
import Intents
|
||||
import PassepartoutLibrary
|
||||
|
||||
@MainActor
|
||||
extension IntentDispatcher {
|
||||
private enum IntentError: Error {
|
||||
case notProvider(UUID)
|
||||
|
|
|
@ -93,7 +93,9 @@ extension IntentsManager: INUIEditVoiceShortcutViewControllerDelegate {
|
|||
// so damn it, reload manually after a delay
|
||||
Task {
|
||||
await Task.maybeWait(forMilliseconds: Constants.Delays.xxxReloadEditedShortcut)
|
||||
reloadShortcuts()
|
||||
await MainActor.run {
|
||||
reloadShortcuts()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@ import Foundation
|
|||
import PassepartoutLibrary
|
||||
|
||||
extension AddProviderView {
|
||||
|
||||
@MainActor
|
||||
class ViewModel: ObservableObject {
|
||||
enum PendingOperation {
|
||||
case index
|
||||
|
|
|
@ -27,6 +27,8 @@ import Foundation
|
|||
import PassepartoutLibrary
|
||||
|
||||
extension CoreContext {
|
||||
|
||||
@MainActor
|
||||
static let shared = CoreContext(store: UserDefaultsStore(defaults: .standard))
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ class CoreContext {
|
|||
|
||||
private var cancellables: Set<AnyCancellable> = []
|
||||
|
||||
@MainActor
|
||||
init(store: KeyValueStore) {
|
||||
self.store = store
|
||||
|
||||
|
|
|
@ -288,8 +288,10 @@ extension DefaultProfileManager {
|
|||
currentProfile.isLoading = true
|
||||
Task {
|
||||
try await makeProfileReady(profile)
|
||||
currentProfile.value = profile
|
||||
currentProfile.isLoading = false
|
||||
await MainActor.run {
|
||||
currentProfile.value = profile
|
||||
currentProfile.isLoading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -334,7 +336,7 @@ extension DefaultProfileManager {
|
|||
|
||||
didUpdateProfiles.send()
|
||||
|
||||
// IMPORTANT: defer task to avoid recursive saves
|
||||
// IMPORTANT: defer task to avoid recursive saves (is non-main thread an issue?)
|
||||
// FIXME: Core Data, not sure about this workaround
|
||||
Task {
|
||||
fixDuplicateNames(in: newHeaders)
|
||||
|
|
|
@ -53,8 +53,10 @@ public class SSIDReader: NSObject, ObservableObject, CLLocationManagerDelegate {
|
|||
private func notifyCurrentSSID() {
|
||||
Task {
|
||||
let currentSSID = await Utils.currentWifiSSID() ?? ""
|
||||
publisher.send(currentSSID)
|
||||
cancellables.removeAll()
|
||||
await MainActor.run {
|
||||
publisher.send(currentSSID)
|
||||
cancellables.removeAll()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ public class MockVPNManagerStrategy: VPNManagerStrategy {
|
|||
public func reinstate(configuration: VPNConfiguration) {
|
||||
}
|
||||
|
||||
@MainActor
|
||||
public func connect(configuration: VPNConfiguration) {
|
||||
guard currentState?.vpnStatus != .connected else {
|
||||
return
|
||||
|
@ -58,6 +59,7 @@ public class MockVPNManagerStrategy: VPNManagerStrategy {
|
|||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
public func disconnect() {
|
||||
stopCountingData()
|
||||
guard currentState?.vpnStatus != .disconnected else {
|
||||
|
@ -92,6 +94,7 @@ public class MockVPNManagerStrategy: VPNManagerStrategy {
|
|||
dataCountTimer = nil
|
||||
}
|
||||
|
||||
@MainActor
|
||||
public func removeConfigurations() {
|
||||
disconnect()
|
||||
}
|
||||
|
|
|
@ -67,7 +67,8 @@ public class TunnelKitVPNManagerStrategy: VPNManagerStrategy {
|
|||
// MARK: Protocol specific
|
||||
|
||||
private var currentBundleIdentifier: String?
|
||||
|
||||
|
||||
@MainActor
|
||||
public init(appGroup: String, tunnelBundleIdentifier: @escaping (VPNProtocolType) -> String, dataCountInterval: TimeInterval = 3.0) {
|
||||
self.appGroup = appGroup
|
||||
self.tunnelBundleIdentifier = tunnelBundleIdentifier
|
||||
|
@ -107,6 +108,7 @@ public class TunnelKitVPNManagerStrategy: VPNManagerStrategy {
|
|||
// use this to drop redundant NE notifications
|
||||
vpnState
|
||||
.removeDuplicates()
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink {
|
||||
self.currentState?.isEnabled = $0.isEnabled
|
||||
self.currentState?.vpnStatus = $0.vpnStatus
|
||||
|
|
Loading…
Reference in New Issue