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.

Build Duplicates' list once per scan, not at every checkbox

Țugui Dragoșe3e553a7dbb7
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 3a37dcee..1f1a3af2 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -168060,6 +168060,112 @@
}
}
},
+ "Select in the groups the list shows" : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Vybrat ve skupinách zobrazených v seznamu"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "In den angezeigten Gruppen auswählen"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Seleccionar en los grupos que muestra la lista"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Sélectionner dans les groupes que la liste affiche"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Seleziona nei gruppi mostrati nell’elenco"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "リストに表示されているグループで選択"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "목록에 표시된 그룹에서 선택"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Selecteer in de groepen die de lijst toont"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Zaznacz w grupach widocznych na liście"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Selecionar nos grupos que a lista mostra"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Selectați în grupurile afișate în listă"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Выбрать в группах, показанных в списке"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Markera i grupperna som listan visar"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Listede gösterilen gruplarda seç"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Вибрати в групах, показаних у списку"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "在列表显示的各组中选择"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "在列表顯示的群組中選取"
+ }
+ }
+ }
+ },
"Select on every page in the list" : {
"localizations" : {
"cs" : {
diff --git a/Peel/Views/Duplicates/DuplicateList.swift b/Peel/Views/Duplicates/DuplicateList.swift
index e9e6b5a1..ab5908e5 100644
--- a/Peel/Views/Duplicates/DuplicateList.swift
+++ b/Peel/Views/Duplicates/DuplicateList.swift
@@ -193,21 +193,15 @@ struct DuplicateList: View {
let scan = duplicates.scan
let groups = scan?.groups.filter { $0.matches(searchText) } ?? []
let folderGroups = scan?.folderGroups.filter { $0.matches(searchText) } ?? []
- let selected = (files: duplicates.selectedURLs, folders: duplicates.selectedFolders)
- let recommended = scan?.selectingRecommended(
- in: groups, folderGroups, files: selected.files, folders: selected.folders
- )
- let none = scan?.deselecting(groups, folderGroups, files: selected.files, folders: selected.folders)
return Menu {
Button("Select Recommended") { duplicates.selectRecommended(in: groups, folderGroups) }
- .disabled(recommended.map { $0 == selected } ?? true)
- Button("Deselect All") { duplicates.deselectAll(in: groups, folderGroups) }
- .disabled(none.map { $0 == selected } ?? true)
+ .disabled(folderGroups.isEmpty && groups.allSatisfy(\.suggestedFiles.isEmpty))
+ DeselectAllDuplicates(duplicates: duplicates, groups: groups, folderGroups: folderGroups)
} label: {
ToolbarMenuLabel(title: "Select", systemImage: "checklist")
}
.disabled(groups.isEmpty && folderGroups.isEmpty || duplicates.isRemoving)
- .help(Text("Select on every page in the list"))
+ .help(Text("Select in the groups the list shows"))
}
/// A new scan clears what the last one found, so it asks first when there is something to lose.
@@ -310,3 +304,15 @@ private struct DuplicateGroupRow: View {
.padding(.vertical, 2)
}
}
+
+/// A view of its own, so that only it reads the selection: the list around it would be built again at every checkbox.
+private struct DeselectAllDuplicates: View {
+ let duplicates: DuplicateLibrary
+ let groups: [DuplicateGroup]
+ let folderGroups: [DuplicateFolderGroup]
+
+ var body: some View {
+ Button("Deselect All") { duplicates.deselectAll(in: groups, folderGroups) }
+ .disabled(duplicates.selectedURLs.isEmpty && duplicates.selectedFolders.isEmpty)
+ }
+}