Skip to content

Commit

Permalink
Merge pull request #5 from Yoshi2889/feature/spinner
Browse files Browse the repository at this point in the history
Add spinner on refresh
  • Loading branch information
NanoSector authored Mar 13, 2021
2 parents b7b1ea0 + 85b0db3 commit 0d004ec
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Brewed/Model/ManagedServices.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class ManagedServices: ObservableObject, FileMonitorDelegate {

@Published var services: [Service] = []

@Published var refreshing = false

private var monitors: [URL: FileMonitor] = [:]

func update(service: Service) {
Expand All @@ -26,6 +28,7 @@ class ManagedServices: ObservableObject, FileMonitorDelegate {
}

func refresh() {
refreshing = true
ListServicesCommand().exec()
.done { services in
self.monitors.removeAll()
Expand All @@ -41,6 +44,8 @@ class ManagedServices: ObservableObject, FileMonitorDelegate {
monitor.delegate = self
}
}
}.ensure {
self.refreshing = false
}.cauterize()
}

Expand Down
4 changes: 4 additions & 0 deletions Brewed/View/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ struct ContentView: View {
)
}
.toolbar {
if managedServices.refreshing {
ProgressView().controlSize(.small)
}

Button(action: {
managedServices.refresh()
}) {
Expand Down
2 changes: 1 addition & 1 deletion Brewed/View/ServiceRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct ServiceRow: View {
}
}
}
}.disabled(executingCommand)
}.disabled(executingCommand || managedServices.refreshing)
}

func run() {
Expand Down

0 comments on commit 0d004ec

Please sign in to comment.