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
Read Extensions again when it is shown and when Peel comes forward
Țugui Dragoș779e8bd7f85a
diff --git a/Peel/Model/ExtensionLibrary.swift b/Peel/Model/ExtensionLibrary.swiftindex b1d74754..741acfa4 100644--- a/Peel/Model/ExtensionLibrary.swift+++ b/Peel/Model/ExtensionLibrary.swift@@ -16,9 +16,29 @@ final class ExtensionLibrary {extensions?.first { $0.id == selection }}+ private let scan: @MainActor (Exclusions) async -> ExtensionScan++ init(+ scan: @escaping @MainActor (Exclusions) async -> ExtensionScan = { await AppExtensions.scan(exclusions: $0) }+ ) {+ self.scan = scan+ }+func refresh() async {- guard let scan = await scanRun.run({ await AppExtensions.scan(exclusions: ExclusionsStore.shared.exclusions) })- else { return }+ let scan = scan+ guard let result = await scanRun.run({ await scan(ExclusionsStore.shared.exclusions) }) else { return }+ show(result)+ }++ /// Reads the page again without showing a scan, once it has been read.+ func readAgain() async {+ guard extensions != nil else { return }+ let scan = scan+ guard let result = await scanRun.runQuietly({ await scan(ExclusionsStore.shared.exclusions) }) else { return }+ show(result)+ }++ private func show(_ scan: ExtensionScan) {let result = scan.extensionsextensions = resultunanswered = scan.unanswereddiff --git a/Peel/Views/Extensions/ExtensionList.swift b/Peel/Views/Extensions/ExtensionList.swiftindex fdb5ae53..7eede193 100644--- a/Peel/Views/Extensions/ExtensionList.swift+++ b/Peel/Views/Extensions/ExtensionList.swift@@ -66,12 +66,19 @@ struct ExtensionList: View {}}}+ // What macOS runs changes in System Settings and with every app installed or removed, so once read the page+ // looks again, quietly, each time it is shown and each time Peel comes forward..task {- guard extensions.extensions == nil, !extensions.scanRun.isWaitedFor, !extensions.scanRun.wasStopped else {+ guard extensions.extensions == nil else {+ await extensions.readAgain()return}+ guard !extensions.scanRun.isWaitedFor, !extensions.scanRun.wasStopped else { return }await extensions.refresh()}+ .onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in+ Task { await extensions.readAgain() }+ }.rescanOnExclusionChange("ExtensionList") { await extensions.refresh() }}diff --git a/PeelTests/ExtensionLibraryTests.swift b/PeelTests/ExtensionLibraryTests.swiftnew file mode 100644index 00000000..5791f4d1--- /dev/null+++ b/PeelTests/ExtensionLibraryTests.swift@@ -0,0 +1,32 @@+import Foundation+@testable import Peel+@testable import PeelCore+import Testing++@MainActor+struct ExtensionLibraryTests {+ private final class Reads {+ var count = 0+ var library: ExtensionLibrary?+ var wereShownAsAScan: [Bool] = []+ }++ @Test func readsAgainWithoutShowingAScan() async {+ let reads = Reads()+ let library = ExtensionLibrary { _ in+ reads.count += 1+ reads.wereShownAsAScan.append(reads.library?.isScanning == true)+ return ExtensionScan(extensions: [], unanswered: reads.count > 1 ? [.systemExtension] : [])+ }+ reads.library = library++ await library.readAgain()+ #expect(reads.count == 0, "nothing is read again before the page was read once")++ await library.refresh()+ await library.readAgain()++ #expect(library.unanswered == [.systemExtension])+ #expect(reads.wereShownAsAScan == [true, false], "a read again is announced to nobody")+ }+}