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.

Show Space's Developer notice with the plan, not seconds after it

Țugui Dragoșba3b69ca2241
diff --git a/Peel/Views/Space/SpaceDetailView.swift b/Peel/Views/Space/SpaceDetailView.swift
index 742d2135..5ae6e6a3 100644
--- a/Peel/Views/Space/SpaceDetailView.swift
+++ b/Peel/Views/Space/SpaceDetailView.swift
@@ -24,8 +24,8 @@ struct SpaceDetailView: View {
if let plan, plan.removable.contains(where: { plan.isLocked($0, canUseHelper: helper.canAct) }) {
HelperRequiredBanner()
}
- if !item.isReadOnly, let plan, !plan.leftToDeveloper.isEmpty, let sizes = plan.developerSizes {
- developerNotice(plan, sizes: sizes)
+ if !item.isReadOnly, let plan, Self.showsDeveloperNotice(for: plan) {
+ developerNotice(plan, sizes: plan.developerSizes ?? [:])
.listRowSeparator(.hidden)
}
@@ -176,6 +176,11 @@ struct SpaceDetailView: View {
}
}
+ /// The notice comes with the plan, without its figures until they are measured, so it never pushes the rows down.
+ static func showsDeveloperNotice(for plan: SpaceRemoval.Plan) -> Bool {
+ !plan.leftToDeveloper.isEmpty
+ }
+
/// Why the area's size in the list is more than this page can move, and where the rest is freed.
private func developerNotice(_ plan: SpaceRemoval.Plan, sizes: [URL: Int64]) -> some View {
let folders = plan.leftToDeveloper
diff --git a/PeelTests/DeveloperNoticeTests.swift b/PeelTests/DeveloperNoticeTests.swift
new file mode 100644
index 00000000..45968cd7
--- /dev/null
+++ b/PeelTests/DeveloperNoticeTests.swift
@@ -0,0 +1,21 @@
+import Foundation
+@testable import Peel
+@testable import PeelCore
+import Testing
+
+@MainActor
+struct DeveloperNoticeTests {
+ @Test func theNoticeComesWithThePlanBeforeItsSizesAreMeasured() {
+ let caches = URL(filePath: "/Users/someone/Library/Caches", directoryHint: .isDirectory)
+ var plan = SpaceRemoval.Plan(
+ removable: [caches.appending(path: "org.example.app")], inUse: [],
+ leftToDeveloper: [caches.appending(path: "Homebrew")], sizes: [:]
+ )
+
+ #expect(SpaceDetailView.showsDeveloperNotice(for: plan))
+ plan.developerSizes = [caches.appending(path: "Homebrew"): 1]
+ #expect(SpaceDetailView.showsDeveloperNotice(for: plan))
+ let nothingLeft = SpaceRemoval.Plan(removable: [], inUse: [], leftToDeveloper: [], sizes: [:])
+ #expect(!SpaceDetailView.showsDeveloperNotice(for: nothingLeft))
+ }
+}