Minor fixes

This commit is contained in:
世界
2023-09-27 13:26:05 +08:00
parent e65680dd55
commit c1d7896d6a
3 changed files with 27 additions and 29 deletions
+22 -22
View File
@@ -92,19 +92,19 @@ public class CommandClient: ObservableObject {
self.commandClient = commandClient self.commandClient = commandClient
} }
nonisolated func connected() { func connected() {
Task { @MainActor [self] in DispatchQueue.main.sync {
self.commandClient.isConnected = true commandClient.isConnected = true
} }
} }
nonisolated func disconnected(_: String?) { func disconnected(_: String?) {
Task { @MainActor [self] in DispatchQueue.main.sync {
self.commandClient.isConnected = false commandClient.isConnected = false
} }
} }
nonisolated func writeLog(_ message: String?) { func writeLog(_ message: String?) {
guard let message else { guard let message else {
return return
} }
@@ -113,18 +113,18 @@ public class CommandClient: ObservableObject {
logList.removeFirst() logList.removeFirst()
} }
logList.append(message) logList.append(message)
Task { @MainActor [self, logList] in DispatchQueue.main.sync {
self.commandClient.logList = logList commandClient.logList = logList
} }
} }
nonisolated func writeStatus(_ message: LibboxStatusMessage?) { func writeStatus(_ message: LibboxStatusMessage?) {
Task { @MainActor [self] in DispatchQueue.main.sync {
self.commandClient.status = message commandClient.status = message
} }
} }
nonisolated func writeGroups(_ groups: LibboxOutboundGroupIteratorProtocol?) { func writeGroups(_ groups: LibboxOutboundGroupIteratorProtocol?) {
guard let groups else { guard let groups else {
return return
} }
@@ -132,21 +132,21 @@ public class CommandClient: ObservableObject {
while groups.hasNext() { while groups.hasNext() {
newGroups.append(groups.next()!) newGroups.append(groups.next()!)
} }
Task { @MainActor [self, newGroups] in DispatchQueue.main.sync {
self.commandClient.groups = newGroups commandClient.groups = newGroups
} }
} }
nonisolated func initializeClashMode(_ modeList: LibboxStringIteratorProtocol?, currentMode: String?) { func initializeClashMode(_ modeList: LibboxStringIteratorProtocol?, currentMode: String?) {
Task { @MainActor [self] in DispatchQueue.main.sync {
self.commandClient.clashModeList = modeList!.toArray() commandClient.clashModeList = modeList!.toArray()
self.commandClient.clashMode = currentMode! commandClient.clashMode = currentMode!
} }
} }
nonisolated func updateClashMode(_ newMode: String?) { func updateClashMode(_ newMode: String?) {
Task { @MainActor [self] in DispatchQueue.main.sync {
self.commandClient.clashMode = newMode! commandClient.clashMode = newMode!
} }
} }
} }
@@ -11,8 +11,8 @@ public class ExtensionPlatformInterface: NSObject, LibboxPlatformInterfaceProtoc
} }
public func openTun(_ options: LibboxTunOptionsProtocol?, ret0_: UnsafeMutablePointer<Int32>?) throws { public func openTun(_ options: LibboxTunOptionsProtocol?, ret0_: UnsafeMutablePointer<Int32>?) throws {
try runBlocking { try runBlocking { [self] in
try await self.openTun0(options, ret0_) try await openTun0(options, ret0_)
} }
} }
@@ -88,7 +88,7 @@ public class ExtensionPlatformInterface: NSObject, LibboxPlatformInterfaceProtoc
let proxyServer = NEProxyServer(address: options.getHTTPProxyServer(), port: Int(options.getHTTPProxyServerPort())) let proxyServer = NEProxyServer(address: options.getHTTPProxyServer(), port: Int(options.getHTTPProxyServerPort()))
proxySettings.httpServer = proxyServer proxySettings.httpServer = proxyServer
proxySettings.httpsServer = proxyServer proxySettings.httpsServer = proxyServer
if try await SharedPreferences.systemProxyEnabled.get() { if await SharedPreferences.systemProxyEnabled.get() {
proxySettings.httpEnabled = true proxySettings.httpEnabled = true
proxySettings.httpsEnabled = true proxySettings.httpsEnabled = true
} }
@@ -96,9 +96,7 @@ public class ExtensionPlatformInterface: NSObject, LibboxPlatformInterfaceProtoc
} }
networkSettings = settings networkSettings = settings
try runBlocking { [self] in try await tunnel.setTunnelNetworkSettings(settings)
try await tunnel.setTunnelNetworkSettings(settings)
}
if let tunFd = tunnel.packetFlow.value(forKeyPath: "socket.fileDescriptor") as? Int32 { if let tunFd = tunnel.packetFlow.value(forKeyPath: "socket.fileDescriptor") as? Int32 {
ret0_.pointee = tunFd ret0_.pointee = tunFd
+1 -1
View File
@@ -757,11 +757,11 @@
3ADF8DF52A4AFA8E00900CC8 /* Profile */ = { 3ADF8DF52A4AFA8E00900CC8 /* Profile */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
3AAB5E752A4BFB0B009757F1 /* EditProfileContentView.swift */,
3ADF8DF62A4AFB2C00900CC8 /* ProfileView.swift */, 3ADF8DF62A4AFB2C00900CC8 /* ProfileView.swift */,
3ADF8DF82A4AFCB400900CC8 /* NewProfileView.swift */, 3ADF8DF82A4AFCB400900CC8 /* NewProfileView.swift */,
3ADF8DFC2A4B096000900CC8 /* EditProfileWindowView.swift */, 3ADF8DFC2A4B096000900CC8 /* EditProfileWindowView.swift */,
3ADF8E002A4B0F6300900CC8 /* EditProfileView.swift */, 3ADF8E002A4B0F6300900CC8 /* EditProfileView.swift */,
3AAB5E752A4BFB0B009757F1 /* EditProfileContentView.swift */,
3AC8CF9A2A736C750002AF3C /* ImportProfileView.swift */, 3AC8CF9A2A736C750002AF3C /* ImportProfileView.swift */,
); );
path = Profile; path = Profile;