Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Let the later helper check's answer stand

Țugui Dragoș132f5182743b
diff --git a/Peel/Model/HelperModel.swift b/Peel/Model/HelperModel.swift
index e43c782b..0a4ea90e 100644
--- a/Peel/Model/HelperModel.swift
+++ b/Peel/Model/HelperModel.swift
@@ -42,10 +42,21 @@ final class HelperModel {
status = PrivilegedHelper.status
}
+ /// Counts the checks, so when two overlap the later one's answer stands, whichever returns last.
+ private var generation = 0
+
func checkConnection() async {
- status = await PrivilegedHelper.currentStatus()
- isResponding = status == .enabled ? await PrivilegedHelper.isResponding() : nil
- isRegisteredByAnotherCopy = status == .notRegistered ? await PrivilegedHelper.isRegisteredByAnyCopy() : false
+ generation += 1
+ let current = generation
+ let status = await PrivilegedHelper.currentStatus()
+ let isResponding = status == .enabled ? await PrivilegedHelper.isResponding() : nil
+ let isRegisteredByAnotherCopy = status == .notRegistered
+ ? await PrivilegedHelper.isRegisteredByAnyCopy()
+ : false
+ guard current == generation else { return }
+ self.status = status
+ self.isResponding = isResponding
+ self.isRegisteredByAnotherCopy = isRegisteredByAnotherCopy
}
/// Registers the helper, and opens Login Items settings when it needs the user's approval. Per