Skip to content

Commit

Permalink
Merge branch 'fixed-maintenance-sheet'
Browse files Browse the repository at this point in the history
  • Loading branch information
buresdv committed Mar 17, 2024
2 parents 207e7cb + c3743d7 commit 419f82e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 39 deletions.
20 changes: 10 additions & 10 deletions Cork/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -10484,13 +10484,13 @@
"plural" : {
"one" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Einige Zwischenspeicher wurden nicht bereinigt, weil of %@ und %lld andere nicht aktuell sind"
}
},
"other" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Einige Zwischenspeicher wurden nicht bereinigt, weil %@ und %lld andere nicht aktuell sind"
}
}
Expand All @@ -10503,13 +10503,13 @@
"one" : {
"stringUnit" : {
"state" : "translated",
"value" : "Some caches weren't purged because of %@ and %lld other package not being updated"
"value" : "Some caches weren't purged because of %1$@ and %2$lld other package not being updated"
}
},
"other" : {
"stringUnit" : {
"state" : "translated",
"value" : "Some caches weren't purged because of %@ and %lld other packages not being updated"
"value" : "Some caches weren't purged because of %1$@ and %2$lld other packages not being updated"
}
}
}
Expand All @@ -10520,13 +10520,13 @@
"plural" : {
"one" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Certains caches n'ont pas été purgés en raison de %@ et %lld autre n'ayant pas été mis à jour"
}
},
"other" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Certains caches n'ont pas été purgés en raison de %@ et %lld autres n'ayant pas été mis à jour"
}
}
Expand Down Expand Up @@ -10568,25 +10568,25 @@
"plural" : {
"few" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Деякі кеші не були очищені через те, що %@ та %lld інших пакета не оновлено"
}
},
"many" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Деякі кеші не були очищені через те, що %@ та %lld інших пакетів не оновлено"
}
},
"one" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Деякі кеші не були очищені через те, що %@ та %lld інший пакет не оновлено"
}
},
"other" : {
"stringUnit" : {
"state" : "translated",
"state" : "needs_review",
"value" : "Деякі кеші не були очищені через те, що %@ та %lld інших пакетів не оновлено"
}
}
Expand Down
70 changes: 41 additions & 29 deletions Cork/Views/Maintenance/Sub-Views/Maintenance Finished View.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,37 @@ struct MaintenanceFinishedView: View

@Binding var maintenanceFoundNoProblems: Bool
@Binding var isShowingSheet: Bool

var displayablePackagesHoldingBackCachePurge: [String]
{
// See if the user wants to see all packages, or just those that are installed manually
// If they only want to see those installed manually, only show those that are holding back cache purge that are actually only installed manually

if displayOnlyIntentionallyInstalledPackagesByDefault
{
/// This abomination of a variable does the following:
/// 1. Filter out only packages that were installed intentionally
/// 2. Get the names of the packages that were installed intentionally
/// 3. Get only the names of packages that were installed intentionally, and are also holding back cache purge
/// **Motivation**: When the user only wants to see packages they have installed intentionally, they will be confused if a dependency suddenly shows up here
//let intentionallyInstalledPackagesHoldingBackCachePurge: [String] = brewData.installedFormulae.filter({ $0.installedIntentionally }).map({ $0.name }).filter{packagesHoldingBackCachePurge.contains($0)}

/// **Motivation**: Same as above, but more performant
/// Instead of looking through all packages, it only looks through packages that are outdated. Since only outdated packages can hold back purging, it kills two birds with one stone
/// Process:
/// 1. Get only the names of outdated packages
/// 2. Get only the names of packages that are outdated, and are holding back cache purge
//let intentionallyInstalledPackagesHoldingBackCachePurge: [String] = outdatedPackageTacker.outdatedPackages.map(\.package.name).filter({ packagesHoldingBackCachePurge.contains($0) })

/// **Motivation**: Same as above, but even more performant
/// Only formulae can hold back cache purging. Therefore, we just filter out the outdated formulae, and those must be holding back the purging
return outdatedPackageTacker.outdatedPackages.filter({ !$0.package.isCask }).map(\.package.name)
}
else
{
return packagesHoldingBackCachePurge
}
}

var body: some View
{
Expand All @@ -52,41 +83,22 @@ struct MaintenanceFinishedView: View
{
Text("maintenance.results.package-cache")

if !packagesHoldingBackCachePurge.isEmpty
if !displayablePackagesHoldingBackCachePurge.isEmpty
{
// See if the user wants to see all packages, or just those that are installed manually
// If they only want to see those installed manually, only show those that are holding back cache purge that are actually only installed manually
if displayOnlyIntentionallyInstalledPackagesByDefault

if displayablePackagesHoldingBackCachePurge.count >= 3
{
/// This abomination of a variable does the following:
/// 1. Filter out only packages that were installed intentionally
/// 2. Get the names of the packages that were installed intentionally
/// 3. Get only the names of packages that were installed intentionally, and are also holding back cache purge
/// **Motivation**: When the user only wants to see packages they have installed intentionally, they will be confused if a dependency suddenly shows up here
//let intentionallyInstalledPackagesHoldingBackCachePurge: [String] = brewData.installedFormulae.filter({ $0.installedIntentionally }).map({ $0.name }).filter{packagesHoldingBackCachePurge.contains($0)}

/// **Motivation**: Same as above, but more performant
/// Instead of looking through all packages, it only looks through packages that are outdated. Since only outdated packages can hold back purging, it kills two birds with one stone
/// Process:
/// 1. Get only the names of outdated packages
/// 2. Get only the names of packages that are outdated, and are holding back cache purge
//let intentionallyInstalledPackagesHoldingBackCachePurge: [String] = outdatedPackageTacker.outdatedPackages.map(\.package.name).filter({ packagesHoldingBackCachePurge.contains($0) })

/// **Motivation**: Same as above, but even more performant
/// Only formulae can hold back cache purging. Therefore, we just filter out the outdated formulae, and those must be holding back the purging
let intentionallyInstalledPackagesHoldingBackCachePurge: [String] = outdatedPackageTacker.outdatedPackages.filter({ !$0.package.isCask }).map(\.package.name)
let packageNamesNotTruncated: [String] = Array(displayablePackagesHoldingBackCachePurge.prefix(3))

if !intentionallyInstalledPackagesHoldingBackCachePurge.isEmpty
{
Text("maintenance.results.package-cache.skipped-\(intentionallyInstalledPackagesHoldingBackCachePurge.formatted(.list(type: .and)))")
.font(.caption)
.foregroundColor(Color(nsColor: NSColor.systemGray))
}
let numberOfTruncatedPackages: Int = displayablePackagesHoldingBackCachePurge.count - packageNamesNotTruncated.count

Text("maintenance.results.package-cache.skipped-\(packageNamesNotTruncated.formatted(.list(type: .and)))-and-\(numberOfTruncatedPackages)-others")
.font(.caption)
.foregroundColor(Color(nsColor: NSColor.systemGray))
}
else
{ // Otherwise, show all of them
Text("maintenance.results.package-cache.skipped-\(packagesHoldingBackCachePurge.formatted(.list(type: .and)))")
{
Text("maintenance.results.package-cache.skipped-\(displayablePackagesHoldingBackCachePurge.formatted(.list(type: .and)))")
.font(.caption)
.foregroundColor(Color(nsColor: NSColor.systemGray))
}
Expand Down

0 comments on commit 419f82e

Please sign in to comment.