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.

Tell VoiceOver how a Rescan of Applications ended

Țugui Dragoșe72b3fde40e2
diff --git a/Peel/Model/AppLibrary.swift b/Peel/Model/AppLibrary.swift
index 2d6bc8ec..c92062f5 100644
--- a/Peel/Model/AppLibrary.swift
+++ b/Peel/Model/AppLibrary.swift
@@ -293,10 +293,19 @@ final class AppLibrary {
/// The round of checks Rescan started, which the next Rescan stops before it starts its own.
@ObservationIgnored private(set) var recheck: Task<Void, Never>?
+ @ObservationIgnored private var rechecks = 0
+ /// True while the round Rescan started runs, so the list can tell VoiceOver what that round found.
+ private(set) var isCheckingEveryApp = false
func checkEveryAppAgain() {
recheck?.cancel()
- recheck = Task { await checkForUpdates(apps, force: true) }
+ rechecks += 1
+ let round = rechecks
+ isCheckingEveryApp = true
+ recheck = Task {
+ await checkForUpdates(apps, force: true)
+ if round == rechecks { isCheckingEveryApp = false }
+ }
}
private func keepUnreadable(of scan: AppScan) {
diff --git a/Peel/Views/AppList.swift b/Peel/Views/AppList.swift
index 1b43eb0a..da9d38d7 100644
--- a/Peel/Views/AppList.swift
+++ b/Peel/Views/AppList.swift
@@ -70,7 +70,11 @@ struct AppList: View {
}
.fadesInColumn(whenRowsChange: library.apps.map(\.id))
.navigationTitle(Text(Tool.applications.title))
- .announcesScan(library.isLoading, found: library.summary)
+ .announcesScan(library.scanRun.isRunning, found: library.summary, wasStopped: library.scanRun.wasStopped)
+ .announcesScan(
+ library.isCheckingEveryApp,
+ found: Tool.applications.sentence(for: Looked(count: library.appsWithUpdates.count, size: nil))
+ )
.toolbar {
ToolbarItem {
ExportMenu()
diff --git a/PeelTests/AppLibraryTests.swift b/PeelTests/AppLibraryTests.swift
index 821b8ff0..a7dadaa8 100644
--- a/PeelTests/AppLibraryTests.swift
+++ b/PeelTests/AppLibraryTests.swift
@@ -596,6 +596,26 @@ private nonisolated final class TestClock: Sendable {
#expect(library.releaseNotes.asks("org.example.fed", version: "1.1"))
}
+ @Test func theRoundRescanStartsSaysWhenItEnds() async throws {
+ let folder = FileManager.default.temporaryDirectory.appending(path: "PeelTests-\(UUID().uuidString)")
+ let bundle = try caskApp("Fed", in: folder, feed: "https://feed.example.com/appcast.xml")
+ defer { try? FileManager.default.removeItem(at: folder) }
+ let made = try MadeUpDefaults()
+ defer { made.forget() }
+ AppcastProtocol.body.withLock { $0 = Data() }
+ let library = library(with: made.defaults, notesIn: folder)
+ #expect(await library.reveal([bundle]))
+
+ library.checkEveryAppAgain()
+ #expect(library.isCheckingEveryApp)
+ let replaced = library.recheck
+ library.checkEveryAppAgain()
+ await replaced?.value
+ #expect(library.isCheckingEveryApp, "the end of a round a newer one replaced says nothing")
+ await library.recheck?.value
+ #expect(!library.isCheckingEveryApp)
+ }
+
@Test func anAppShownFromElsewhereIsNeitherCountedNorExported() async throws {
let folder = FileManager.default.temporaryDirectory.appending(path: "PeelTests-\(UUID().uuidString)")
let bundle = try caskApp("Fed", in: folder, feed: "https://feed.example.com/appcast.xml")