mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-22 14:26:01 +00:00
Only allow one alert message at a time
This commit is contained in:
1 parent
23705c5e26
commit
404e25d3bd
1 file changed
+10
-5
@@ -23,6 +23,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
|
|||||||
var welcomeWindow: NSWindow?
|
var welcomeWindow: NSWindow?
|
||||||
var plusWindow: NSWindow?
|
var plusWindow: NSWindow?
|
||||||
|
|
||||||
|
private var isAlertShown = false
|
||||||
private var sheetView: NSPanel? = nil
|
private var sheetView: NSPanel? = nil
|
||||||
private var sheetAttachedWindow: NSWindow? = nil
|
private var sheetAttachedWindow: NSWindow? = nil
|
||||||
|
|
||||||
@@ -453,11 +454,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
|
|||||||
|
|
||||||
|
|
||||||
func incomingTransfer(id: String, didFinishWith error: Error?) {
|
func incomingTransfer(id: String, didFinishWith error: Error?) {
|
||||||
|
|
||||||
guard let transfer = activeIncomingTransfers[id] else { return }
|
guard let transfer = activeIncomingTransfers[id] else { return }
|
||||||
|
|
||||||
if let error = error {
|
if let error = error {
|
||||||
|
|
||||||
NSApp.activate(ignoringOtherApps: true)
|
NSApp.activate(ignoringOtherApps: true)
|
||||||
|
|
||||||
var description = ""
|
var description = ""
|
||||||
@@ -485,10 +484,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
|
|||||||
|
|
||||||
let alert = NSAlert()
|
let alert = NSAlert()
|
||||||
alert.alertStyle = .critical
|
alert.alertStyle = .critical
|
||||||
|
|
||||||
alert.messageText = String(format: NSLocalizedString("TransferError", value: "Failed to receive files from %@", comment: ""), arguments: [transfer.device.name])
|
alert.messageText = String(format: NSLocalizedString("TransferError", value: "Failed to receive files from %@", comment: ""), arguments: [transfer.device.name])
|
||||||
alert.informativeText = description
|
alert.informativeText = description
|
||||||
|
|
||||||
alert.addButton(withTitle: "InformDeveloper".localized())
|
alert.addButton(withTitle: "InformDeveloper".localized())
|
||||||
alert.addButton(withTitle: "CloseAlert".localized())
|
alert.addButton(withTitle: "CloseAlert".localized())
|
||||||
|
|
||||||
@@ -497,17 +494,25 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
|
|||||||
plusWindow.close()
|
plusWindow.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Prevent multiple alerts at the same time
|
||||||
|
if self.isAlertShown {
|
||||||
|
log("Skipping alert for error \(error.localizedDescription) because one is already shown")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
self.isAlertShown = true
|
||||||
log("Showing alert with message: \"\(alert.messageText)\" and description: \"\(alert.informativeText)\"")
|
log("Showing alert with message: \"\(alert.messageText)\" and description: \"\(alert.informativeText)\"")
|
||||||
log("Already successful transmissions: \(transmissionCount())")
|
log("Already successful transmissions: \(transmissionCount())")
|
||||||
|
|
||||||
let result = alert.runModal()
|
let result = alert.runModal()
|
||||||
|
self.isAlertShown = false
|
||||||
|
|
||||||
if result == .alertFirstButtonReturn {
|
if result == .alertFirstButtonReturn {
|
||||||
sendLoggingString()
|
sendLoggingString()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let currentCount = transmissionCount()
|
let currentCount = transmissionCount()
|
||||||
|
|
||||||
if currentCount % 20 == 0 {
|
if currentCount % 20 == 0 {
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
||||||
SKStoreReviewController.requestReview()
|
SKStoreReviewController.requestReview()
|
||||||
|
|||||||
Reference in new issue
Block a user