Commit 5c59605f by Demid Merzlyakov

Storage: fix selected location updates.

parent 8e13f07c
......@@ -79,8 +79,6 @@ public class LocationManager {
return _locations
}
set {
let oldSelectedLocation = self.selectedLocation
if let selectedLocation = self.selectedLocation {
if let newSelectedIndex = newValue.firstIndex(where: { $0 == selectedLocation }) {
_selectedLocationIndex = newSelectedIndex
......@@ -94,8 +92,7 @@ public class LocationManager {
_selectedLocationIndex = 0
}
_locations = newValue
let selectedLocationChanged = (oldSelectedLocation != self.selectedLocation)
handleLocationsChange(locationsChanged: true, selectedLocationChanged: selectedLocationChanged)
handleLocationsChange(locationsChanged: true, selectedLocationChanged: true)
}
}
......@@ -261,7 +258,7 @@ public class LocationManager {
DispatchQueue.main.async {
self.log.info("Update weather finished for \(location)")
if let indexToUpdate = self.locations.firstIndex(where: { $0 == updatedLocation }) {
self.locations[indexToUpdate] = updatedLocation
self.locations[indexToUpdate] = self.locations[indexToUpdate].mergedWith(incrementalChanges: updatedLocation)
}
else if self.defaultLocation == updatedLocation {
self.defaultLocation = self.defaultLocation.mergedWith(incrementalChanges: updatedLocation)
......@@ -272,7 +269,6 @@ public class LocationManager {
}
}
}
// TODO: update weather for all locations
public func addIfNeeded(location: Location, selectLocation: Bool) {
// If the location is partially incomplete (e.g. coordinates are missing, or country / city / region), then some of this information will be returned by the weather update, but we may need to consider reverse geocoding here as well, if needed.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment