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.

Make History's Reload look at the disk again

Țugui Dragoș56b897ccf574
diff --git a/Peel/Model/RemovalHistoryStore.swift b/Peel/Model/RemovalHistoryStore.swift
index 22f3993d..3869e1d5 100644
--- a/Peel/Model/RemovalHistoryStore.swift
+++ b/Peel/Model/RemovalHistoryStore.swift
@@ -132,6 +132,8 @@ final class RemovalHistoryStore {
/// sits in many batches.
var selectedIDs: Set<RemovalRecord.ID> = []
var failures: [RemovalRecord.ID: RestoreFailure] = [:]
+ /// Counts the reloads asked for, so a removal's page looks in the Trash again with each.
+ private(set) var reloads = 0
/// Counts each change of what History lists. The lists are prepared off the main actor, and one prepared for an
/// older change must never replace a newer one.
private var listedChange = 0
@@ -151,6 +153,14 @@ final class RemovalHistoryStore {
hasLoaded = true
}
+ /// Shows History as a page opened anew would: read again, without the reasons the last Put Back gave, and with
+ /// the Trash looked at again.
+ func reload() async {
+ failures = [:]
+ reloads += 1
+ await load()
+ }
+
/// The problem History's page shows: that History cannot be read, as soon as that is known, otherwise what the
/// last read or change of it met.
var shownProblem: RemovalLogProblem? {
diff --git a/Peel/Views/History/HistoryDetailView.swift b/Peel/Views/History/HistoryDetailView.swift
index 5a7c1634..479fd102 100644
--- a/Peel/Views/History/HistoryDetailView.swift
+++ b/Peel/Views/History/HistoryDetailView.swift
@@ -18,11 +18,12 @@ struct HistoryDetailView: View {
@State private var failures: [(record: RemovalRecord, failure: RestoreFailure)] = []
let batch: RemovalBatch
- /// The id of the page's task: the batch, and whether the window is key. When either changes, the page reads
- /// the disk again, since the Trash may have been emptied in the meantime.
+ /// The id of the page's task: the batch, whether the window is key, and the reloads asked for. When any changes,
+ /// the page reads the disk again, since the Trash may have been emptied in the meantime.
private struct Look: Hashable {
let batch: RemovalBatch
let isActive: Bool
+ let reloads: Int
}
/// The size of what can still be put back. Until the disk has answered, it is the batch's own total.
@@ -57,7 +58,7 @@ struct HistoryDetailView: View {
}
.navigationTitle(Text(verbatim: batch.title))
.toolbar(removing: .title)
- .task(id: Look(batch: batch, isActive: controlActiveState == .key)) {
+ .task(id: Look(batch: batch, isActive: controlActiveState == .key, reloads: history.reloads)) {
standing = await RemovalStanding.of(batch.records)
}
.task(id: batch.id) {
diff --git a/Peel/Views/History/HistoryList.swift b/Peel/Views/History/HistoryList.swift
index d80f93cc..654679cf 100644
--- a/Peel/Views/History/HistoryList.swift
+++ b/Peel/Views/History/HistoryList.swift
@@ -88,7 +88,7 @@ struct HistoryList: View {
.toolbar {
ToolbarItem {
RescanButton(isRunning: $isReloading, title: "Reload") {
- await history.load()
+ await history.reload()
}
}
}