Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Tell of no update while Check for app updates is off
Țugui Dragoșc70387323361
diff --git a/Packages/PeelCore/Sources/PeelCore/Updates/AnnouncedUpdates.swift b/Packages/PeelCore/Sources/PeelCore/Updates/AnnouncedUpdates.swiftindex b7f08b16..017de299 100644--- a/Packages/PeelCore/Sources/PeelCore/Updates/AnnouncedUpdates.swift+++ b/Packages/PeelCore/Sources/PeelCore/Updates/AnnouncedUpdates.swift@@ -8,11 +8,18 @@ public struct AnnouncedUpdates: Equatable, Sendable {}/// The apps in `waiting` whose update `version` hasn't been told of, which then count as told. None while a round- /// of checks runs, so an update is told of once every round that may find it has ended.+ /// of checks runs, so an update is told of once every round that may find it has ended, and none while the checks+ /// are off, so what waits then is told once they are on again.public mutating func takeNew(- _ waiting: [InstalledApp], version: (InstalledApp) -> String?, whileChecking isChecking: Bool+ _ waiting: [InstalledApp], version: (InstalledApp) -> String?, whileChecking isChecking: Bool, checksAreOn: Bool) -> [InstalledApp] {- guard !isChecking else { return [] }+ guard !isChecking, checksAreOn else { return [] }+ return note(waiting, version: version)+ }++ /// Counts the updates in `waiting` as told of, and answers the apps whose update wasn't yet.+ @discardableResult+ public mutating func note(_ waiting: [InstalledApp], version: (InstalledApp) -> String?) -> [InstalledApp] {let new = waiting.compactMap { app inversion(app).flatMap { versions[app.reference] == $0 ? nil : (app, $0) }}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/AnnouncedUpdatesTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/AnnouncedUpdatesTests.swiftindex 727663bb..254897ef 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/AnnouncedUpdatesTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/AnnouncedUpdatesTests.swift@@ -13,15 +13,35 @@ struct AnnouncedUpdatesTests {@Test func tellsOfEachUpdateOnceWhoeverFoundIt() {var versions = ["org.example.editor": "2.0", "org.example.viewer": "5.0"]var told = AnnouncedUpdates()+ func new(_ waiting: [InstalledApp], whileChecking: Bool = false) -> [InstalledApp] {+ told.takeNew(waiting, version: { versions[$0.reference] }, whileChecking: whileChecking, checksAreOn: true)+ }- #expect(told.takeNew([editor], version: { versions[$0.reference] }, whileChecking: true).isEmpty)- #expect(told.takeNew([editor], version: { versions[$0.reference] }, whileChecking: false) == [editor])- #expect(told.takeNew([editor, viewer], version: { versions[$0.reference] }, whileChecking: false) == [viewer])- #expect(told.takeNew([editor, viewer], version: { versions[$0.reference] }, whileChecking: false).isEmpty)+ #expect(new([editor], whileChecking: true).isEmpty)+ #expect(new([editor]) == [editor])+ #expect(new([editor, viewer]) == [viewer])+ #expect(new([editor, viewer]).isEmpty)versions["org.example.editor"] = "2.1"- let relaunched = AnnouncedUpdates(versions: told.versions)- var again = relaunched- #expect(again.takeNew([editor, viewer], version: { versions[$0.reference] }, whileChecking: false) == [editor])+ var again = AnnouncedUpdates(versions: told.versions)+ let relaunched = again.takeNew(+ [editor, viewer], version: { versions[$0.reference] }, whileChecking: false, checksAreOn: true+ )+ #expect(relaunched == [editor])+ }++ @Test func tellsOfNothingWhileTheChecksAreOffAndOfWhatWaitsOnceTheyAreOn() {+ let versions = ["org.example.editor": "2.0", "org.example.viewer": "5.0"]+ let version = { (app: InstalledApp) in versions[app.reference] }+ var told = AnnouncedUpdates()++ let whileOff = told.takeNew([editor], version: version, whileChecking: false, checksAreOn: false)+ let onceOn = told.takeNew([editor], version: version, whileChecking: false, checksAreOn: true)+ told.note([viewer], version: version)+ let noted = told.takeNew([viewer], version: version, whileChecking: false, checksAreOn: true)++ #expect(whileOff.isEmpty)+ #expect(onceOn == [editor])+ #expect(noted.isEmpty, "an update noted as told is not told again")}}diff --git a/Peel/Model/AppLibrary.swift b/Peel/Model/AppLibrary.swiftindex 3aa60ff9..cebd40ee 100644--- a/Peel/Model/AppLibrary.swift+++ b/Peel/Model/AppLibrary.swift@@ -388,8 +388,9 @@ final class AppLibrary {}}// Before Peel noted what it told of, the updates found earlier were told of as they were found.- if defaults.object(forKey: SettingsKey.announcedUpdates) == nil {- _ = updatesToAnnounce()+ if !apps.isEmpty, defaults.object(forKey: SettingsKey.announcedUpdates) == nil {+ announced.note(appsWithUpdates, version: { updateStatuses[$0.id]?.version })+ defaults.set(announced.versions, forKey: SettingsKey.announcedUpdates)}}@@ -765,12 +766,15 @@ final class AppLibrary {var menuBarUpdateCount: Int { menuBarUpdates.count }/// The installed apps whose waiting update no notification has named, which then count as named- /// (`AnnouncedUpdates`), kept across launches.+ /// (`AnnouncedUpdates`), kept across launches. None while Check for app updates is off.func updatesToAnnounce() -> [InstalledApp] {let new = announced.takeNew(- appsWithUpdates, version: { updateStatuses[$0.id]?.version }, whileChecking: !appsCheckingForUpdates.isEmpty+ appsWithUpdates,+ version: { updateStatuses[$0.id]?.version },+ whileChecking: !appsCheckingForUpdates.isEmpty,+ checksAreOn: defaults.isOn(SettingsKey.checksForAppUpdates, whenNeverSet: true))- if !new.isEmpty || defaults.object(forKey: SettingsKey.announcedUpdates) == nil {+ if !new.isEmpty {defaults.set(announced.versions, forKey: SettingsKey.announcedUpdates)}return new