Fix popups not reloaded on provider change

This commit is contained in:
Davide De Rosa 2021-01-03 15:30:23 +01:00
parent 51373a36f2
commit 34de924c4a
1 changed files with 15 additions and 9 deletions

View File

@ -160,22 +160,28 @@ class ProviderServiceView: NSView {
popupCategory.addItem(withTitle: categoryTitle) popupCategory.addItem(withTitle: categoryTitle)
} }
if let (a, b, c) = selectPopupsFromCurrentProfile() { let (a, b, c) = selectPopupsFromCurrentProfile()
if popupCategory.numberOfItems > 0 {
popupCategory.selectItem(at: a) popupCategory.selectItem(at: a)
loadLocations(withCategory: a) loadLocations(withCategory: a)
popupLocation.selectItem(at: b) if popupLocation.numberOfItems > 0 {
loadAreas(withLocation: b) popupLocation.selectItem(at: b)
popupArea.selectItem(at: c) loadAreas(withLocation: b)
if popupArea.numberOfItems > 0 {
currentCategoryIndex = a popupArea.selectItem(at: c)
currentLocationIndex = b }
}
} }
currentCategoryIndex = a
currentLocationIndex = b
if let lastInfrastructureUpdate = InfrastructureFactory.shared.modificationDate(forName: profile.name) { if let lastInfrastructureUpdate = InfrastructureFactory.shared.modificationDate(forName: profile.name) {
labelLastInfrastructureUpdate.stringValue = L10n.Core.Service.Sections.ProviderInfrastructure.footer(lastInfrastructureUpdate.timestamp) labelLastInfrastructureUpdate.stringValue = L10n.Core.Service.Sections.ProviderInfrastructure.footer(lastInfrastructureUpdate.timestamp)
} }
} }
private func selectPopupsFromCurrentProfile() -> (Int, Int, Int)? { private func selectPopupsFromCurrentProfile() -> (Int, Int, Int) {
for (a, category) in categories.enumerated() { for (a, category) in categories.enumerated() {
guard let groups = sortedGroupsByCategory[category.name] else { guard let groups = sortedGroupsByCategory[category.name] else {
continue continue
@ -190,7 +196,7 @@ class ProviderServiceView: NSView {
} }
} }
} }
return nil return (0, 0, 0)
} }
private func loadLocations(withCategory index: Int) { private func loadLocations(withCategory index: Int) {