Signal file provider changes on VPN status update
This commit is contained in:
@@ -213,6 +213,7 @@ public struct CoreView: View {
|
|||||||
guard let manager = NSFileProviderManager(for: domain) else {
|
guard let manager = NSFileProviderManager(for: domain) else {
|
||||||
throw NSError(domain: "CoreView", code: 0, userInfo: [NSLocalizedDescriptionKey: "Failed to get file provider manager"])
|
throw NSError(domain: "CoreView", code: 0, userInfo: [NSLocalizedDescriptionKey: "Failed to get file provider manager"])
|
||||||
}
|
}
|
||||||
|
try await manager.signalEnumerator(for: .workingSet)
|
||||||
let url = try await manager.getUserVisibleURL(for: .rootContainer)
|
let url = try await manager.getUserVisibleURL(for: .rootContainer)
|
||||||
guard let sharedURL = URL(string: "shareddocuments://\(url.path)") else {
|
guard let sharedURL = URL(string: "shareddocuments://\(url.path)") else {
|
||||||
throw NSError(domain: "CoreView", code: 0, userInfo: [NSLocalizedDescriptionKey: "Failed to create shared documents URL"])
|
throw NSError(domain: "CoreView", code: 0, userInfo: [NSLocalizedDescriptionKey: "Failed to create shared documents URL"])
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ import Foundation
|
|||||||
import Libbox
|
import Libbox
|
||||||
import NetworkExtension
|
import NetworkExtension
|
||||||
import os
|
import os
|
||||||
|
#if os(iOS)
|
||||||
|
import FileProvider
|
||||||
|
#endif
|
||||||
|
|
||||||
private let logger = Logger(category: "ExtensionProfile")
|
private let logger = Logger(category: "ExtensionProfile")
|
||||||
|
|
||||||
@@ -39,10 +42,32 @@ public class ExtensionProfile: ObservableObject {
|
|||||||
self.connection = connection
|
self.connection = connection
|
||||||
self.status = connection.status
|
self.status = connection.status
|
||||||
self.connectedDate = connection.connectedDate
|
self.connectedDate = connection.connectedDate
|
||||||
|
#if os(iOS)
|
||||||
|
if #available(iOS 16.0, *) {
|
||||||
|
if connection.status == .connected || connection.status == .disconnected {
|
||||||
|
Self.signalFileProviderChanges()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if os(iOS)
|
||||||
|
@available(iOS 16.0, *)
|
||||||
|
private static func signalFileProviderChanges() {
|
||||||
|
Task.detached {
|
||||||
|
guard let domain = try? await NSFileProviderManager.domains()
|
||||||
|
.first(where: { $0.identifier.rawValue == AppConfiguration.fileProviderDomainID }),
|
||||||
|
let manager = NSFileProviderManager(for: domain)
|
||||||
|
else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try? await manager.signalEnumerator(for: .workingSet)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
private func unregister() {
|
private func unregister() {
|
||||||
if let observer {
|
if let observer {
|
||||||
NotificationCenter.default.removeObserver(observer)
|
NotificationCenter.default.removeObserver(observer)
|
||||||
|
|||||||
Reference in New Issue
Block a user