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
355b39f0
Commit
355b39f0
authored
Mar 26, 2021
by
Demid Merzlyakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Device Location merging improved.
parent
5cb58cd4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
6 deletions
+7
-6
1Weather/Model/LocationManager.swift
+4
-1
1Weather/Model/ModelObjects/Location.swift
+3
-5
No files found.
1Weather/Model/LocationManager.swift
View file @
355b39f0
...
...
@@ -126,9 +126,11 @@ public class LocationManager {
// This may happen if a location is added from a push notification.
}
if
location
.
deviceLocation
{
if
locations
.
first
?
.
deviceLocation
==
true
{
if
let
firstLocation
=
locations
.
first
,
firstLocation
.
deviceLocation
{
if
firstLocation
!=
location
{
locations
[
0
]
=
location
}
}
else
{
locations
=
[
location
]
+
locations
}
...
...
@@ -208,6 +210,7 @@ public class LocationManager {
log
.
error
(
"Geo lookup: no coordinates present:
\(
partialLocation
)
"
)
var
location
:
Location
?
=
nil
if
partialLocation
.
deviceLocation
{
log
.
debug
(
"Adding a placeholder empty device location."
)
location
=
Location
(
deviceLocation
:
true
,
timeZone
:
TimeZone
.
current
)
}
completion
(
location
)
...
...
1Weather/Model/ModelObjects/Location.swift
View file @
355b39f0
...
...
@@ -69,8 +69,8 @@ public struct Location {
extension
Location
:
Equatable
,
Hashable
{
public
static
func
==
(
lhs
:
Self
,
rhs
:
Self
)
->
Bool
{
if
lhs
.
deviceLocation
&&
rhs
.
deviceLocation
{
return
tru
e
guard
lhs
.
deviceLocation
==
rhs
.
deviceLocation
else
{
return
fals
e
}
if
let
lCoordinates
=
lhs
.
coordinates
,
let
rCoordinates
=
rhs
.
coordinates
{
return
lCoordinates
==
rCoordinates
...
...
@@ -79,10 +79,8 @@ extension Location: Equatable, Hashable {
}
public
func
hash
(
into
hasher
:
inout
Hasher
)
{
if
deviceLocation
{
hasher
.
combine
(
deviceLocation
)
}
else
if
let
coordinates
=
self
.
coordinates
{
if
let
coordinates
=
self
.
coordinates
{
hasher
.
combine
(
coordinates
)
}
else
{
...
...
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