Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Commit 453d354

Browse files
authoredAug 5, 2022
Prevent the app from quitting while the Fire button is active (#670)
Task/Issue URL: https://app.asana.com/0/1177771139624306/1202342287825730/f Tech Design URL: CC: Description: This PR cancels termination if the Fire button is burning data when quitting is attempted.
1 parent bf0a6bb commit 453d354

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed
 

‎DuckDuckGo/App Delegate/AppDelegate.swift

+6
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,15 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
128128
if alert.runModal() == .cancel {
129129
return .terminateCancel
130130
}
131+
131132
FileDownloadManager.shared.cancelAll(waitUntilDone: true)
132133
DownloadListCoordinator.shared.sync()
133134
}
135+
136+
if FireCoordinator.fireViewModel.isBurning {
137+
return .terminateLater
138+
}
139+
134140
stateRestorationManager?.applicationWillTerminate()
135141

136142
return .terminateNow

‎DuckDuckGo/Fire/Model/Fire.swift

+2
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ final class Fire {
215215
completion?()
216216

217217
os_log("Fire finished", log: .fire)
218+
NSApp.reply(toApplicationShouldTerminate: true)
218219
}
219220
}
220221
}
@@ -264,6 +265,7 @@ final class Fire {
264265
completion?()
265266

266267
os_log("Fire finished", log: .fire)
268+
NSApp.reply(toApplicationShouldTerminate: true)
267269
}
268270
}
269271
}

‎DuckDuckGo/Fire/ViewModel/FireViewModel.swift

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ final class FireViewModel {
2525

2626
@Published var isAnimationPlaying = false
2727

28+
var isBurning: Bool {
29+
fire.burningData != nil
30+
}
31+
2832
/// Publisher that emits true if burning animation or burning process is in progress
2933
var shouldPreventUserInteraction: AnyPublisher<Bool, Never> {
3034
Publishers

0 commit comments

Comments
 (0)