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