1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-11-09 21:20:07 +01:00

👌 Show spinner when busy

This commit is contained in:
2021-12-05 04:14:55 +01:00
parent e0bec333ed
commit d8fc857d23
3 changed files with 54 additions and 15 deletions

View File

@@ -15,6 +15,7 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
// MARK: - Outlets
@IBOutlet weak var tableView: NSTableView!
@IBOutlet weak var progressIndicator: NSProgressIndicator!
// MARK: - Variables
@@ -64,21 +65,32 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
}
self.sites = Valet.shared.sites
self.progressIndicator.stopAnimation(nil)
}
// MARK: - Site Data Loading
func reloadSites() {
// Reload site information
Valet.shared.reloadSites()
// Start spinner and reset view (no items)
self.progressIndicator.startAnimation(nil)
self.sites = []
self.tableView.reloadData()
// Update the site list
self.sites = Valet.shared.sites
// Re-apply any existing search
self.searchedFor(text: lastSearchedFor)
DispatchQueue.global(qos: .userInitiated).async { [unowned self] in
// Reload site information
Valet.shared.reloadSites()
DispatchQueue.main.async { [self] in
// Update the site list
self.sites = Valet.shared.sites
// Stop spinner
self.progressIndicator.stopAnimation(nil)
// Re-apply any existing search
self.searchedFor(text: lastSearchedFor)
}
}
}
// MARK: - Table View