From 7e0a2e283003c0c4e82c25e87db6163105f27cbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20B=C3=B6ttger?= Date: Thu, 19 Feb 2026 21:35:14 +0100 Subject: [PATCH] Toast view cancel all connections with xmark --- NearbyShare/Connection/NearbyConnectionManager.swift | 7 +++++++ QuickDrop/ViewModel/ReceiveModel.swift | 9 ++++----- 2 files changed, 11 insertions(+), 5 deletions(-) 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)