Skip to content

Commit c5570a5

Browse files
committed
~ Refactoring of partial update sheet
1 parent 175e3e6 commit c5570a5

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

Cork/ContentView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,8 @@ private extension View
498498
case .fullUpdate:
499499
UpdatePackagesView()
500500

501-
case .partialUpdate:
502-
UpdateSomePackagesView()
501+
case .partialUpdate(let packagesToUpdate):
502+
UpdateSomePackagesView(packagesToUpdate: packagesToUpdate)
503503

504504
case .corruptedPackageFix(let corruptedPackage):
505505
ReinstallCorruptedPackageView(corruptedPackageToReinstall: corruptedPackage)

Cork/Enums/Sheets/Main Window/Sheets - Main Window.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ enum DisplayableSheet: Identifiable, Equatable
1414

1515
case tapAddition
1616

17-
case fullUpdate, partialUpdate
17+
case fullUpdate, partialUpdate(packagesToUpdate: [OutdatedPackage])
1818

1919
case corruptedPackageFix(corruptedPackage: CorruptedPackage)
2020

Cork/Views/Menu Bar/Sub-Views/Menu Bar - Package Updating.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct MenuBar_PackageUpdating: View
2525
{
2626
if let sanitizedSheetState = appState.sheetToShow
2727
{
28-
if sanitizedSheetState != .fullUpdate || sanitizedSheetState != .partialUpdate
28+
if sanitizedSheetState != .fullUpdate || sanitizedSheetState != .partialUpdate(packagesToUpdate: .init())
2929
{
3030
Menu
3131
{

Cork/Views/Start Page/Sub-Views/Outdated Packages/Outdated Package List Box.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ struct OutdatedPackageListBox: View
108108
{
109109
Button
110110
{
111-
appState.showSheet(ofType: .partialUpdate)
111+
appState.showSheet(ofType: .partialUpdate(packagesToUpdate: packagesMarkedForUpdating))
112112
} label: {
113113
Text("start-page.update-incremental.package-count-\(packagesMarkedForUpdating.count)")
114114
}

Cork/Views/Updating/Incremental Updating/Update Some Packages View.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ struct UpdateSomePackagesView: View
2020

2121
@State private var packageUpdatingErrors: [String] = .init()
2222

23-
var selectedPackages: [OutdatedPackage]
23+
let packagesToUpdate: [OutdatedPackage]
24+
25+
var numberOfPackagesToUpdate: Int
2426
{
25-
return outdatedPackageTracker.displayableOutdatedPackages.filter { $0.isMarkedForUpdating }
27+
packagesToUpdate.count
2628
}
2729

2830
var body: some View
@@ -32,14 +34,14 @@ struct UpdateSomePackagesView: View
3234
switch packageUpdatingStage
3335
{
3436
case .updating:
35-
ProgressView(value: updateProgress, total: Double(selectedPackages.count))
37+
ProgressView(value: updateProgress, total: Double(packagesToUpdate.count))
3638
{
3739
Text("update-packages.incremental.update-in-progress-\(packageBeingCurrentlyUpdated.name)")
3840
}
3941
.frame(width: 200)
4042
.task
4143
{
42-
for (index, outdatedPackage) in selectedPackages.enumerated()
44+
for (index, outdatedPackage) in packagesToUpdate.enumerated()
4345
{
4446
packageBeingCurrentlyUpdated = outdatedPackage.package
4547

@@ -62,11 +64,11 @@ struct UpdateSomePackagesView: View
6264
{
6365
case .standardOutput(let outputLine):
6466
AppConstants.shared.logger.info("Individual package updating output: \(outputLine)")
65-
updateProgress = updateProgress + (Double(selectedPackages.count) / 100)
67+
updateProgress = updateProgress + (Double(numberOfPackagesToUpdate) / 100)
6668

6769
case .standardError(let errorLine):
6870
AppConstants.shared.logger.info("Individual package updating error: \(errorLine)")
69-
updateProgress = updateProgress + (Double(selectedPackages.count) / 100)
71+
updateProgress = updateProgress + (Double(numberOfPackagesToUpdate) / 100)
7072

7173
if !errorLine.contains("The post-install step did not complete successfully")
7274
{

0 commit comments

Comments
 (0)