1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-11-06 04:40:07 +01:00

🐛 Fix delay due to use of async

This commit is contained in:
2022-02-20 14:26:56 +01:00
parent 6b3c562af2
commit ae7b285eb0

View File

@@ -47,22 +47,19 @@ class ServicesView: NSView, XibLoadable {
override func viewWillDraw() { override func viewWillDraw() {
super.viewWillDraw() super.viewWillDraw()
self.loadData() Task { await self.loadData() }
} }
@objc func updateInformation() { @objc func updateInformation() {
self.loadData() Task { await self.loadData() }
} }
func loadData() { func loadData() async {
self.applyAllInfoFieldsFromCachedValue() self.applyAllInfoFieldsFromCachedValue()
Task {
let services = await HomebrewService.loadAll() let services = await HomebrewService.loadAll()
ServicesView.services = Dictionary(uniqueKeysWithValues: services.map{ ($0.name, $0) }) ServicesView.services = Dictionary(uniqueKeysWithValues: services.map{ ($0.name, $0) })
self.applyAllInfoFieldsFromCachedValue() self.applyAllInfoFieldsFromCachedValue()
} }
}
func applyAllInfoFieldsFromCachedValue() { func applyAllInfoFieldsFromCachedValue() {
if ServicesView.services.keys.isEmpty { if ServicesView.services.keys.isEmpty {