mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
refactor(apple): Annotate update resources callback @MainActor (#8069)
Followup to the discussion on https://github.com/firezone/firezone/pull/8064. By annotating the callback that updates our Resources `@MainActor`, the compiler will correctly warn us when we call it from a non-isolated context.
This commit is contained in:
@@ -320,7 +320,7 @@ public class VPNConfigurationManager {
|
||||
updateInternetResourceState()
|
||||
}
|
||||
|
||||
func fetchResources(callback: @escaping (ResourceList) -> Void) {
|
||||
func fetchResources(callback: @escaping @MainActor (ResourceList) -> Void) {
|
||||
guard session()?.status == .connected else { return }
|
||||
|
||||
do {
|
||||
@@ -338,7 +338,7 @@ public class VPNConfigurationManager {
|
||||
self.resourcesListCache = ResourceList.loaded(decoded)
|
||||
}
|
||||
|
||||
callback(self.resourcesListCache)
|
||||
Task { await MainActor.run { callback(self.resourcesListCache) } }
|
||||
}
|
||||
} catch {
|
||||
Log.error(error)
|
||||
|
||||
@@ -160,7 +160,7 @@ public final class Store: ObservableObject {
|
||||
|
||||
// Network Extensions don't have a 2-way binding up to the GUI process,
|
||||
// so we need to periodically ask the tunnel process for them.
|
||||
func beginUpdatingResources(callback: @escaping (ResourceList) -> Void) {
|
||||
func beginUpdatingResources(callback: @escaping @MainActor (ResourceList) -> Void) {
|
||||
Log.log("\(#function)")
|
||||
|
||||
if self.resourcesTimer != nil {
|
||||
|
||||
@@ -63,7 +63,6 @@ public final class SessionViewModel: ObservableObject {
|
||||
public func isInternetResourceEnabled() -> Bool {
|
||||
store.internetResourceEnabled()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
|
||||
Reference in New Issue
Block a user