Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Sep 12, 2024
1 parent 31d63f4 commit 20f70a5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions ApplicationLibrary/Views/Profile/ImportProfileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,26 @@
private func reset() {
selected = false
profiles = nil
if let connection = connection {
connection.cancel()
self.connection = nil

}
}

private func handleEndpoint(_ endpoint: NWEndpoint) async {
let connection = NWConnection(to: endpoint, using: NWParameters.applicationService)
self.connection = NWSocket(connection)
connection.stateUpdateHandler = { state in
switch state {
case .failed(let error):
DispatchQueue.main.async { [self] in
reset()
alert = Alert(error)
}
default: break
}
}
connection.start(queue: .global())
do {
try await loopMessages()
Expand Down Expand Up @@ -176,6 +191,7 @@
lastUpdated = Date(timeIntervalSince1970: Double(content.lastUpdated))
}
try await ProfileManager.create(Profile(name: content.name, type: type, path: profileConfig.relativePath, remoteURL: content.remotePath, autoUpdate: content.autoUpdate, lastUpdated: lastUpdated))
await reset()
await callback()
await MainActor.run {
dismiss()
Expand Down

0 comments on commit 20f70a5

Please sign in to comment.