Fix toast view disappears if new connection comes right after

This commit is contained in:
Leon Böttger committed 2026-02-22 16:12:02 +01:00
1 parent 7e0a2e2830
commit c489ef018f
3 files changed
+21 -9

No files matched your search

+4 -4
View File
@@ -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;
@@ -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"
}
},
{
+14 -2
View File
@@ -25,6 +25,7 @@ class ReceiveModel: ObservableObject, InboundAppDelegate {
private var toastWindowPending = false
private var toastWindow: NSWindow?
private var toastHosting: NSHostingView<QuickDropToastHostView>?
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)
}