diff --git a/NearbyShare/Connection/NearbyConnectionManager.swift b/NearbyShare/Connection/NearbyConnectionManager.swift index 6811682..29cad70 100644 --- a/NearbyShare/Connection/NearbyConnectionManager.swift +++ b/NearbyShare/Connection/NearbyConnectionManager.swift @@ -482,6 +482,13 @@ public class NearbyConnectionManager: NSObject, NetServiceDelegate, InboundNearb } } + public func cancelAllIncomingConnections() { + let incomingTransfers = Array(incomingConnections.values) + for transfer in incomingTransfers { + transfer.cancel() + } + } + private func endpointID(for service: NWBrowser.Result) -> String? { guard case let NWEndpoint.service(name: serviceName, type: _, domain: _, interface: _) = service.endpoint else { return nil } guard let nameData = Data.dataFromUrlSafeBase64(serviceName) else { return nil } diff --git a/QuickDrop/ViewModel/ReceiveModel.swift b/QuickDrop/ViewModel/ReceiveModel.swift index 3d5c28d..02a36b0 100644 --- a/QuickDrop/ViewModel/ReceiveModel.swift +++ b/QuickDrop/ViewModel/ReceiveModel.swift @@ -458,12 +458,11 @@ class ReceiveModel: ObservableObject, InboundAppDelegate { let contentView = QuickDropToastHostView( receiveModel: self, onCancel: { [weak self] in - NearbyConnectionManager.shared.cancelTransfer(id: connectionID) guard let self else { return } - self.processes.removeValue(forKey: connectionID) - if self.processes.isEmpty { - self.progress = nil - } + NearbyConnectionManager.shared.cancelAllIncomingConnections() + + self.processes.removeAll() + self.progress = nil self.toastActions = nil self.consentState = nil self.hideQuickDropToast(style: .fade)