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
}
nonisolated func connected() {
Task { @MainActor [self] in
self.commandClient.isConnected = true
func connected() {
DispatchQueue.main.sync {
commandClient.isConnected = true
}
}
nonisolated func disconnected(_: String?) {
Task { @MainActor [self] in
self.commandClient.isConnected = false
func disconnected(_: String?) {
DispatchQueue.main.sync {
commandClient.isConnected = false
}
}
nonisolated func writeLog(_ message: String?) {
func writeLog(_ message: String?) {
guard let message else {
return
}
@@ -113,18 +113,18 @@ public class CommandClient: ObservableObject {
logList.removeFirst()
}
logList.append(message)
Task { @MainActor [self, logList] in
self.commandClient.logList = logList
DispatchQueue.main.sync {
commandClient.logList = logList
}
}
nonisolated func writeStatus(_ message: LibboxStatusMessage?) {
Task { @MainActor [self] in
self.commandClient.status = message
func writeStatus(_ message: LibboxStatusMessage?) {
DispatchQueue.main.sync {
commandClient.status = message
}
}
nonisolated func writeGroups(_ groups: LibboxOutboundGroupIteratorProtocol?) {
func writeGroups(_ groups: LibboxOutboundGroupIteratorProtocol?) {
guard let groups else {
return
}
@@ -132,21 +132,21 @@ public class CommandClient: ObservableObject {
while groups.hasNext() {
newGroups.append(groups.next()!)
}
Task { @MainActor [self, newGroups] in
self.commandClient.groups = newGroups
DispatchQueue.main.sync {
commandClient.groups = newGroups
}
}
nonisolated func initializeClashMode(_ modeList: LibboxStringIteratorProtocol?, currentMode: String?) {
Task { @MainActor [self] in
self.commandClient.clashModeList = modeList!.toArray()
self.commandClient.clashMode = currentMode!
func initializeClashMode(_ modeList: LibboxStringIteratorProtocol?, currentMode: String?) {
DispatchQueue.main.sync {
commandClient.clashModeList = modeList!.toArray()
commandClient.clashMode = currentMode!
}
}
nonisolated func updateClashMode(_ newMode: String?) {
Task { @MainActor [self] in
self.commandClient.clashMode = newMode!
func updateClashMode(_ newMode: String?) {
DispatchQueue.main.sync {
commandClient.clashMode = newMode!
}
}
}
@@ -11,8 +11,8 @@ public class ExtensionPlatformInterface: NSObject, LibboxPlatformInterfaceProtoc
}
public func openTun(_ options: LibboxTunOptionsProtocol?, ret0_: UnsafeMutablePointer<Int32>?) throws {
try runBlocking {
try await self.openTun0(options, ret0_)
try runBlocking { [self] in
try await openTun0(options, ret0_)
}
}
@@ -88,7 +88,7 @@ public class ExtensionPlatformInterface: NSObject, LibboxPlatformInterfaceProtoc
let proxyServer = NEProxyServer(address: options.getHTTPProxyServer(), port: Int(options.getHTTPProxyServerPort()))
proxySettings.httpServer = proxyServer
proxySettings.httpsServer = proxyServer
if try await SharedPreferences.systemProxyEnabled.get() {
if await SharedPreferences.systemProxyEnabled.get() {
proxySettings.httpEnabled = true
proxySettings.httpsEnabled = true
}
@@ -96,9 +96,7 @@ public class ExtensionPlatformInterface: NSObject, LibboxPlatformInterfaceProtoc
}
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 {
ret0_.pointee = tunFd
+1 -1
View File
@@ -757,11 +757,11 @@
3ADF8DF52A4AFA8E00900CC8 /* Profile */ = {
isa = PBXGroup;
children = (
3AAB5E752A4BFB0B009757F1 /* EditProfileContentView.swift */,
3ADF8DF62A4AFB2C00900CC8 /* ProfileView.swift */,
3ADF8DF82A4AFCB400900CC8 /* NewProfileView.swift */,
3ADF8DFC2A4B096000900CC8 /* EditProfileWindowView.swift */,
3ADF8E002A4B0F6300900CC8 /* EditProfileView.swift */,
3AAB5E752A4BFB0B009757F1 /* EditProfileContentView.swift */,
3AC8CF9A2A736C750002AF3C /* ImportProfileView.swift */,
);
path = Profile;