[ADD] Refresh all apps functionality in MyAppsView

This commit is contained in:
Fabian Thies
2023-02-19 14:25:13 +01:00
parent 00dc9b36af
commit f206ee1406
2 changed files with 14 additions and 8 deletions

View File

@@ -75,7 +75,7 @@ struct AppPillButton: View {
} }
func refreshApp(_ installedApp: InstalledApp) { func refreshApp(_ installedApp: InstalledApp) {
AppManager.shared.refresh([installedApp], presentingViewController: nil)
} }
func installApp(_ storeApp: StoreApp) { func installApp(_ storeApp: StoreApp) {

View File

@@ -38,7 +38,7 @@ struct MyAppsView: View {
var viewModel = MyAppsViewModel() var viewModel = MyAppsViewModel()
// TODO: Refactor // TODO: Refactor
@State var isShowingFilePicker: Bool = false @State var isRefreshingAllApps: Bool = false
@State var selectedSideloadingIpaURL: URL? @State var selectedSideloadingIpaURL: URL?
@State var isShowingAppIDsView: Bool = false @State var isShowingAppIDsView: Bool = false
@@ -89,11 +89,14 @@ struct MyAppsView: View {
Text(L10n.MyAppsView.active) Text(L10n.MyAppsView.active)
.font(.title2) .font(.title2)
.bold() .bold()
Spacer() Spacer()
SwiftUI.Button {
} label: { if !self.isRefreshingAllApps {
Text(L10n.MyAppsView.refreshAll) SwiftUI.Button(L10n.MyAppsView.refreshAll, action: self.refreshAllApps)
} else {
ProgressView()
.progressViewStyle(CircularProgressViewStyle())
} }
} }
@@ -206,7 +209,10 @@ struct MyAppsView: View {
func refreshAllApps() { func refreshAllApps() {
let installedApps = InstalledApp.fetchAppsForRefreshingAll(in: DatabaseManager.shared.viewContext) let installedApps = InstalledApp.fetchAppsForRefreshingAll(in: DatabaseManager.shared.viewContext)
self.refresh(installedApps) { result in } self.isRefreshingAllApps = true
self.refresh(installedApps) { result in
self.isRefreshingAllApps = false
}
} }
func dismissUpdatesHint(forever: Bool) { func dismissUpdatesHint(forever: Bool) {
@@ -218,7 +224,7 @@ struct MyAppsView: View {
extension MyAppsView { extension MyAppsView {
// TODO: Convert to async // TODO: Convert to async?
func refresh(_ apps: [InstalledApp], completionHandler: @escaping ([String : Result<InstalledApp, Error>]) -> Void) { func refresh(_ apps: [InstalledApp], completionHandler: @escaping ([String : Result<InstalledApp, Error>]) -> Void) {
let group = AppManager.shared.refresh(apps, presentingViewController: nil, group: self.viewModel.refreshGroup) let group = AppManager.shared.refresh(apps, presentingViewController: nil, group: self.viewModel.refreshGroup)
@@ -248,10 +254,10 @@ extension MyAppsView {
NotificationManager.shared.showNotification(title: title, detailText: message) NotificationManager.shared.showNotification(title: title, detailText: message)
} }
}
self.viewModel.refreshGroup = nil self.viewModel.refreshGroup = nil
completionHandler(results) completionHandler(results)
}
} }
self.viewModel.refreshGroup = group self.viewModel.refreshGroup = group