Fix macOS toast view autohide

This commit is contained in:
Leon Böttger committed 2025-11-18 20:39:13 +01:00
1 parent 0c440b7511
commit f948c30027
3 files changed
+15 -9

No files matched your search

+2 -2
View File
@@ -1319,7 +1319,7 @@
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
SHARED_BUILD = 88;
SHARED_BUILD = 89;
SHARED_VERSION = 2.6.1;
STRING_CATALOG_GENERATE_SYMBOLS = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
@@ -1382,7 +1382,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = macosx;
SHARED_BUILD = 88;
SHARED_BUILD = 89;
SHARED_VERSION = 2.6.1;
STRING_CATALOG_GENERATE_SYMBOLS = YES;
SWIFT_COMPILATION_MODE = wholemodule;
+3 -6
View File
@@ -14,7 +14,7 @@ struct QuickDropToastView: View {
@ObservedObject var settings = Settings.shared
@ObservedObject var receiveModel: ReceiveModel
@State var autoHider: DispatchWorkItem? = nil
@State var autoHider = DispatchWorkItem(block: {})
/// Cancel while receiving.
public var onCancel: () -> Void
@@ -79,12 +79,10 @@ struct QuickDropToastView: View {
actions.closeToastAction()
})
DispatchQueue.main.asyncAfter(deadline: .now() + 10) {
self.autoHider?.perform()
}
DispatchQueue.main.asyncAfter(deadline: .now() + 10, execute: self.autoHider)
}
.onDisappear {
self.autoHider?.cancel()
self.autoHider.cancel()
}
}
.buttonStyle(.bordered)
@@ -116,7 +114,6 @@ struct QuickDropToastView: View {
)
.shadow(color: Color.black.opacity(0.1), radius: 20)
.frame(maxWidth: .infinity)
.opacity(isFileTransferRestricted() ? 0 : 1)
}
}
+10 -1
View File
@@ -23,6 +23,7 @@ class ReceiveModel: ObservableObject, InboundAppDelegate {
#if os(macOS)
@Published var progress: Double? = nil
@Published var toastActions: ToastViewAction? = nil
private var pendingReview = false
private var toastWindow: NSWindow?
private var toastHosting: NSHostingView<QuickDropToastView>?
#endif
@@ -231,6 +232,10 @@ class ReceiveModel: ObservableObject, InboundAppDelegate {
#if os(macOS)
if currentCount == 0 {
pendingReview = true
}
let openFilesAction = {
if !savedFiles.isEmpty {
log("[SaveFilesManager] Opening \(savedFiles.count) file(s) in Finder.")
@@ -285,7 +290,11 @@ class ReceiveModel: ObservableObject, InboundAppDelegate {
func showReviewIfAppropriate(currentTransmissionCount: Int) {
// If distributed directly, do not request review here as it does not work
if currentTransmissionCount == 0 && !DistributionDetector.isDirectDistributionEnabled {
if pendingReview && !DistributionDetector.isDirectDistributionEnabled {
// Dont request review again
pendingReview = false
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
SKStoreReviewController.requestReview()
}