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
4d515dda
Commit
4d515dda
authored
Mar 30, 2021
by
Demid Merzlyakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix weather updates for the default location.
parent
2c5ac8c1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
1Weather/Model/LocationManager.swift
+17
-3
No files found.
1Weather/Model/LocationManager.swift
View file @
4d515dda
...
...
@@ -20,9 +20,17 @@ public class LocationManager {
private
let
deviceLocationMonitor
:
DeviceLocationMonitor
private
let
weatherUpdateSource
:
WeatherSource
private
let
defaultLocation
=
Location
(
deviceLocation
:
false
,
private
var
defaultLocation
=
Location
(
deviceLocation
:
false
,
coordinates
:
.
init
(
latitude
:
37.3230
,
longitude
:
-
122.0322
),
// Cupertino
timeZone
:
TimeZone
(
abbreviation
:
"PST"
)
!
)
timeZone
:
TimeZone
(
abbreviation
:
"PST"
)
!
)
{
didSet
{
if
locations
.
count
==
0
{
self
.
delegates
.
invoke
{
(
delegate
)
in
delegate
.
locationManager
(
self
,
changedSelectedLocation
:
defaultLocation
)
}
}
}
}
public
enum
LocationRequestResult
{
/// User provided us with location permissions, we can use the current location.
...
...
@@ -150,10 +158,16 @@ public class LocationManager {
}
DispatchQueue
.
main
.
async
{
self
.
log
.
info
(
"Update weather finished for location:
\(
location
)
"
)
if
let
indexToUpdate
=
self
.
locations
.
firstIndex
(
where
:
{
$0
==
updatedLocation
})
{
self
.
locations
[
indexToUpdate
]
=
updatedLocation
}
else
if
self
.
defaultLocation
==
updatedLocation
{
self
.
defaultLocation
=
self
.
defaultLocation
.
mergedWith
(
incrementalChanges
:
updatedLocation
)
}
else
{
self
.
log
.
warning
(
"Update weather: Failed to find location after update. Maybe it was deleted while the update was performed. Maybe something went wrong. Location:
\(
updatedLocation
)
"
)
}
}
}
}
...
...
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