From c489ef018f11f67825badfc4127a9b70a86700a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20B=C3=B6ttger?= Date: Sun, 22 Feb 2026 16:12:02 +0100 Subject: [PATCH] Fix toast view disappears if new connection comes right after --- QuickDrop.xcodeproj/project.pbxproj | 8 ++++---- .../xcshareddata/swiftpm/Package.resolved | 6 +++--- QuickDrop/ViewModel/ReceiveModel.swift | 16 ++++++++++++++-- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/QuickDrop.xcodeproj/project.pbxproj b/QuickDrop.xcodeproj/project.pbxproj index b4ffbec..2d9078f 100644 --- a/QuickDrop.xcodeproj/project.pbxproj +++ b/QuickDrop.xcodeproj/project.pbxproj @@ -1739,8 +1739,8 @@ MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; - SHARED_BUILD = 124; - SHARED_VERSION = 2.13; + SHARED_BUILD = 126; + SHARED_VERSION = 2.13.1; STRING_CATALOG_GENERATE_SYMBOLS = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_EMIT_LOC_STRINGS = YES; @@ -1802,8 +1802,8 @@ MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = macosx; - SHARED_BUILD = 124; - SHARED_VERSION = 2.13; + SHARED_BUILD = 126; + SHARED_VERSION = 2.13.1; STRING_CATALOG_GENERATE_SYMBOLS = YES; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_EMIT_LOC_STRINGS = YES; diff --git a/QuickDrop.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/QuickDrop.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index d327566..26e93bf 100644 --- a/QuickDrop.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/QuickDrop.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -52,7 +52,7 @@ "location" : "https://github.com/leonboe1/LUI.git", "state" : { "branch" : "main", - "revision" : "5862b50de0ba0dcf61e3796ed4e6baaf194067de" + "revision" : "24e35e2829f478d4219e82921302321dae6c1e78" } }, { @@ -87,8 +87,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-protobuf.git", "state" : { - "revision" : "c5ab62237f21cad094812719a1bbe29443407c5f", - "version" : "1.34.1" + "revision" : "9bbb079b69af9d66470ced85461bf13bb40becac", + "version" : "1.35.0" } }, { diff --git a/QuickDrop/ViewModel/ReceiveModel.swift b/QuickDrop/ViewModel/ReceiveModel.swift index 02a36b0..91a8283 100644 --- a/QuickDrop/ViewModel/ReceiveModel.swift +++ b/QuickDrop/ViewModel/ReceiveModel.swift @@ -25,6 +25,7 @@ class ReceiveModel: ObservableObject, InboundAppDelegate { private var toastWindowPending = false private var toastWindow: NSWindow? private var toastHosting: NSHostingView? + private var toastCleanupTask: DispatchWorkItem? private let monitor = AllowedWorkMonitor() #endif @@ -437,6 +438,10 @@ class ReceiveModel: ObservableObject, InboundAppDelegate { return } + // If a previous hide is still waiting for cleanup, keep the toast alive for this new request. + toastCleanupTask?.cancel() + toastCleanupTask = nil + if let window = toastWindow { toastDismissStyle = .slide toastIsVisible = true @@ -552,6 +557,9 @@ class ReceiveModel: ObservableObject, InboundAppDelegate { return } + toastCleanupTask?.cancel() + toastCleanupTask = nil + guard let window = toastWindow else { self.toastWindow = nil self.toastHosting = nil @@ -565,8 +573,8 @@ class ReceiveModel: ObservableObject, InboundAppDelegate { self.toastIsVisible = false let cleanupDelay: TimeInterval = (style == .slide) ? 0.5 : 0.3 - - DispatchQueue.main.asyncAfter(deadline: .now() + cleanupDelay) { + let cleanupTask = DispatchWorkItem { [weak self] in + guard let self else { return } window.orderOut(nil) self.toastWindow = nil self.toastHosting = nil @@ -574,7 +582,11 @@ class ReceiveModel: ObservableObject, InboundAppDelegate { self.consentState = nil self.activeDeviceName = nil self.toastWindowPending = false + self.toastCleanupTask = nil } + toastCleanupTask = cleanupTask + + DispatchQueue.main.asyncAfter(deadline: .now() + cleanupDelay, execute: cleanupTask) }