From d1641281452cd521148ba82d14dc878d7c8ae498 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Thu, 29 Oct 2020 17:23:10 +0400 Subject: [PATCH] Fix location view --- submodules/LocationUI/Sources/LocationAnnotation.swift | 4 +++- submodules/LocationUI/Sources/LocationMapNode.swift | 3 +++ .../LocationUI/Sources/LocationViewControllerNode.swift | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/submodules/LocationUI/Sources/LocationAnnotation.swift b/submodules/LocationUI/Sources/LocationAnnotation.swift index 794f77a612..37aa915541 100644 --- a/submodules/LocationUI/Sources/LocationAnnotation.swift +++ b/submodules/LocationUI/Sources/LocationAnnotation.swift @@ -52,6 +52,7 @@ class LocationPinAnnotation: NSObject, MKAnnotation { } } + var isSelf = false var selfPeer: Peer? var title: String? = "" var subtitle: String? = "" @@ -78,11 +79,12 @@ class LocationPinAnnotation: NSObject, MKAnnotation { super.init() } - init(context: AccountContext, theme: PresentationTheme, message: Message, selfPeer: Peer?, heading: Int32?) { + init(context: AccountContext, theme: PresentationTheme, message: Message, selfPeer: Peer?, isSelf: Bool, heading: Int32?) { self.context = context self.theme = theme self.location = nil self.peer = nil + self.isSelf = isSelf self.message = message if let location = getLocation(from: message) { self.coordinate = location.coordinate diff --git a/submodules/LocationUI/Sources/LocationMapNode.swift b/submodules/LocationUI/Sources/LocationMapNode.swift index e3360c4a09..7b77bd64bf 100644 --- a/submodules/LocationUI/Sources/LocationMapNode.swift +++ b/submodules/LocationUI/Sources/LocationMapNode.swift @@ -481,6 +481,9 @@ final class LocationMapNode: ASDisplayNode, MKMapViewDelegate { var distances: [Double] = [] if let userLocation = userLocation { for annotation in annotations { + if annotation.isSelf { + continue + } distances.append(userLocation.distance(from: CLLocation(latitude: annotation.coordinate.latitude, longitude: annotation.coordinate.longitude))) } } diff --git a/submodules/LocationUI/Sources/LocationViewControllerNode.swift b/submodules/LocationUI/Sources/LocationViewControllerNode.swift index f076d7bc44..b6d64c05cd 100644 --- a/submodules/LocationUI/Sources/LocationViewControllerNode.swift +++ b/submodules/LocationUI/Sources/LocationViewControllerNode.swift @@ -413,9 +413,9 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan let distance = userLocation.flatMap { subjectLocation.distance(from: $0) } if message.localTags.contains(.OutgoingLiveLocation), let selfPeer = selfPeer { - userAnnotation = LocationPinAnnotation(context: context, theme: presentationData.theme, message: message, selfPeer: selfPeer, heading: location.heading) + userAnnotation = LocationPinAnnotation(context: context, theme: presentationData.theme, message: message, selfPeer: selfPeer, isSelf: true, heading: location.heading) } else { - annotations.append(LocationPinAnnotation(context: context, theme: presentationData.theme, message: message, selfPeer: selfPeer, heading: location.heading)) + annotations.append(LocationPinAnnotation(context: context, theme: presentationData.theme, message: message, selfPeer: selfPeer, isSelf: message.author?.id == context.account.peerId, heading: location.heading)) entries.append(.liveLocation(presentationData.theme, presentationData.dateTimeFormat, presentationData.nameDisplayOrder, message, distance, index)) } index += 1