Skip to content

Commit

Permalink
Merge branch 'main' into feature/start_watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
NanoSector authored Mar 13, 2021
2 parents 1cee8a4 + 0d004ec commit 5dbec90
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 @@ -10,6 +10,8 @@ import Foundation
class ManagedServices: ObservableObject, FileMonitorDelegate, FolderMonitorDelegate {
@Published var services: [Service] = []

@Published var refreshing = false

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

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

func refresh() {
refreshing = true
ListServicesCommand().exec()
.done { services in
self.monitors.removeAll()
Expand All @@ -48,6 +51,8 @@ class ManagedServices: ObservableObject, FileMonitorDelegate, FolderMonitorDeleg
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 5dbec90

Please sign in to comment.