Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
1
1weather
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
1weather
Commits
5c59605f
Commit
5c59605f
authored
Apr 07, 2021
by
Demid Merzlyakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Storage: fix selected location updates.
parent
8e13f07c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
6 deletions
+2
-6
1Weather/Model/LocationManager.swift
+2
-6
No files found.
1Weather/Model/LocationManager.swift
View file @
5c59605f
...
...
@@ -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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment