From e00eeec6ae60048c68cbace4afc42718fe7e37d8 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Fri, 23 Oct 2020 00:55:07 +0400 Subject: [PATCH] Update API --- .../Telegram-iOS/en.lproj/Localizable.strings | 4 - .../Sources/InstantPageLayout.swift | 2 +- .../Sources/LegacyChatImport.swift | 2 +- .../Sources/LiveLocationManager.swift | 2 +- .../ChatMessageLiveLocationPositionNode.swift | 5 +- .../Sources/LegacyLocationController.swift | 2 +- .../Sources/LocationAnnotation.swift | 4 +- .../LocationDistancePickerScreen.swift | 15 ++-- .../LocationUI/Sources/LocationMapNode.swift | 2 +- .../Sources/LocationPickerController.swift | 4 +- .../LocationPickerControllerNode.swift | 4 +- .../Sources/LocationSearchContainerNode.swift | 2 +- .../LocationUI/Sources/LocationUtils.swift | 2 +- .../Sources/LocationViewController.swift | 21 ++--- .../Sources/LocationViewControllerNode.swift | 34 ++++--- .../Sources/GroupInfoController.swift | 2 +- .../ShareItems/Sources/ShareItems.swift | 4 +- .../Sources/SlotMachineAnimationNode.swift | 2 +- .../SyncCore/Sources/TelegramMediaMap.swift | 19 +++- submodules/TelegramApi/Sources/Api0.swift | 4 +- submodules/TelegramApi/Sources/Api1.swift | 60 ++++++++----- submodules/TelegramApi/Sources/Api3.swift | 17 ---- .../TelegramCore/Sources/AccountManager.swift | 1 - .../Sources/AccountStateManagementUtils.swift | 8 -- .../Sources/ChatContextResult.swift | 4 +- .../Sources/PeerLiveLocationsContext.swift | 90 ------------------- .../PendingMessageUploadedContent.swift | 6 +- ...ecretChatIncomingDecryptedOperations.swift | 12 +-- .../Sources/RequestEditMessage.swift | 8 +- .../Sources/StoreMessage_Telegram.swift | 8 +- .../Sources/TelegramMediaMap.swift | 6 +- .../TelegramUI/Sources/ChatController.swift | 2 +- .../ChatMessageInteractiveFileNode.swift | 14 +-- .../ChatRecentActionsHistoryTransition.swift | 2 +- .../Sources/PeerInfo/PeerInfoScreen.swift | 2 +- .../Sources/WatchRequestHandlers.swift | 2 +- 36 files changed, 134 insertions(+), 244 deletions(-) diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index f611d242b5..aa3cfbbb33 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -5859,10 +5859,6 @@ Any member of this group will be able to see messages in the channel."; "Location.ProximityNotification.DistanceKM" = "KM"; "Location.ProximityNotification.DistanceMI" = "MI"; -"Location.LiveLocationRequired.Title" = "Share Location"; -"Location.LiveLocationRequired.Description" = "For the alert to work, please share your live location in this chat."; -"Location.LiveLocationRequired.ShareLocation" = "Share Location"; - "Location.ProximityTip" = "Alert when %@ is close"; "Location.ProximityGroupTip" = "Alert when any group member is close"; diff --git a/submodules/InstantPageUI/Sources/InstantPageLayout.swift b/submodules/InstantPageUI/Sources/InstantPageLayout.swift index d1d5c4bd8d..a57edfc0ac 100644 --- a/submodules/InstantPageUI/Sources/InstantPageLayout.swift +++ b/submodules/InstantPageUI/Sources/InstantPageLayout.swift @@ -816,7 +816,7 @@ func layoutInstantPageBlock(webpage: TelegramMediaWebpage, rtl: Bool, block: Ins } } - let map = TelegramMediaMap(latitude: latitude, longitude: longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil) + let map = TelegramMediaMap(latitude: latitude, longitude: longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil) let attributes: [InstantPageImageAttribute] = [InstantPageMapAttribute(zoom: zoom, dimensions: dimensions.cgSize)] var contentSize = CGSize(width: boundingWidth - safeInset * 2.0, height: 0.0) diff --git a/submodules/LegacyDataImport/Sources/LegacyChatImport.swift b/submodules/LegacyDataImport/Sources/LegacyChatImport.swift index c1c77fd37f..9a50a1471a 100644 --- a/submodules/LegacyDataImport/Sources/LegacyChatImport.swift +++ b/submodules/LegacyDataImport/Sources/LegacyChatImport.swift @@ -553,7 +553,7 @@ private func loadLegacyMessages(account: TemporaryAccount, basePath: String, acc if let v = item.venue { venue = MapVenue(title: v.title ?? "", address: v.address ?? "", provider: v.provider == "" ? nil : v.provider, id: v.venueId == "" ? nil : v.venueId, type: v.type == "" ? nil : v.type) } - parsedMedia.append(TelegramMediaMap(latitude: item.latitude, longitude: item.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: venue, liveBroadcastingTimeout: nil)) + parsedMedia.append(TelegramMediaMap(latitude: item.latitude, longitude: item.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: venue, liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil)) } } } diff --git a/submodules/LiveLocationManager/Sources/LiveLocationManager.swift b/submodules/LiveLocationManager/Sources/LiveLocationManager.swift index ca36297c12..6a38d86270 100644 --- a/submodules/LiveLocationManager/Sources/LiveLocationManager.swift +++ b/submodules/LiveLocationManager/Sources/LiveLocationManager.swift @@ -247,7 +247,7 @@ public final class LiveLocationManagerImpl: LiveLocationManager { let timestamp = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970) for i in 0 ..< updatedMedia.count { if let media = updatedMedia[i] as? TelegramMediaMap, let _ = media.liveBroadcastingTimeout { - updatedMedia[i] = TelegramMediaMap(latitude: media.latitude, longitude: media.longitude, heading: media.heading, accuracyRadius: media.accuracyRadius, geoPlace: media.geoPlace, venue: media.venue, liveBroadcastingTimeout: max(0, timestamp - currentMessage.timestamp - 1)) + updatedMedia[i] = TelegramMediaMap(latitude: media.latitude, longitude: media.longitude, heading: media.heading, accuracyRadius: media.accuracyRadius, geoPlace: media.geoPlace, venue: media.venue, liveBroadcastingTimeout: max(0, timestamp - currentMessage.timestamp - 1), liveProximityNotificationRadius: nil) } } return .update(StoreMessage(id: currentMessage.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, threadId: currentMessage.threadId, timestamp: currentMessage.timestamp, flags: StoreMessageFlags(currentMessage.flags), tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: currentMessage.attributes, media: updatedMedia)) diff --git a/submodules/LiveLocationPositionNode/Sources/ChatMessageLiveLocationPositionNode.swift b/submodules/LiveLocationPositionNode/Sources/ChatMessageLiveLocationPositionNode.swift index 0e37146b6a..2d6429d89e 100644 --- a/submodules/LiveLocationPositionNode/Sources/ChatMessageLiveLocationPositionNode.swift +++ b/submodules/LiveLocationPositionNode/Sources/ChatMessageLiveLocationPositionNode.swift @@ -78,7 +78,7 @@ private func generateHeadingArrowImage() -> UIImage? { public final class ChatMessageLiveLocationPositionNode: ASDisplayNode { public enum Mode { - case liveLocation(peer: Peer, active: Bool, latitude: Double, longitude: Double, heading: Double?) + case liveLocation(peer: Peer, active: Bool, latitude: Double, longitude: Double, heading: Int32?) case location(TelegramMediaMap?) } @@ -152,7 +152,7 @@ public final class ChatMessageLiveLocationPositionNode: ASDisplayNode { backgroundImage = avatarBackgroundImage hasPulse = active coordinate = (latitude, longitude) - heading = headingValue + heading = headingValue.flatMap { Double($0) } case let .location(location): let venueType = location?.venue?.type ?? "" let color = venueType.isEmpty ? theme.list.itemAccentColor : venueIconColor(type: venueType) @@ -166,7 +166,6 @@ public final class ChatMessageLiveLocationPositionNode: ASDisplayNode { return degrees * Double.pi / 180.0 } - if heading == nil, let currentCoordinate = currentCoordinate, let coordinate = coordinate { let lat1 = degToRad(currentCoordinate.0) let lon1 = degToRad(currentCoordinate.1) diff --git a/submodules/LocationUI/Sources/LegacyLocationController.swift b/submodules/LocationUI/Sources/LegacyLocationController.swift index ef4e426ffa..3411e9a7ee 100644 --- a/submodules/LocationUI/Sources/LegacyLocationController.swift +++ b/submodules/LocationUI/Sources/LegacyLocationController.swift @@ -122,7 +122,7 @@ private func telegramMap(for location: TGLocationMediaAttachment) -> TelegramMed } else { mapVenue = nil } - return TelegramMediaMap(latitude: location.latitude, longitude: location.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: mapVenue, liveBroadcastingTimeout: nil) + return TelegramMediaMap(latitude: location.latitude, longitude: location.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: mapVenue, liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil) } func legacyLocationPalette(from theme: PresentationTheme) -> TGLocationPallete { diff --git a/submodules/LocationUI/Sources/LocationAnnotation.swift b/submodules/LocationUI/Sources/LocationAnnotation.swift index c6f1bef1b0..d9c23c0de8 100644 --- a/submodules/LocationUI/Sources/LocationAnnotation.swift +++ b/submodules/LocationUI/Sources/LocationAnnotation.swift @@ -43,7 +43,7 @@ class LocationPinAnnotation: NSObject, MKAnnotation { let peer: Peer? let message: Message? let forcedSelection: Bool - var heading: Double? { + var heading: Int32? { willSet { self.willChangeValue(forKey: "heading") } @@ -78,7 +78,7 @@ class LocationPinAnnotation: NSObject, MKAnnotation { super.init() } - init(context: AccountContext, theme: PresentationTheme, message: Message, selfPeer: Peer?, heading: Double?) { + init(context: AccountContext, theme: PresentationTheme, message: Message, selfPeer: Peer?, heading: Int32?) { self.context = context self.theme = theme self.location = nil diff --git a/submodules/LocationUI/Sources/LocationDistancePickerScreen.swift b/submodules/LocationUI/Sources/LocationDistancePickerScreen.swift index 8f0f5efa38..3de2345ce9 100644 --- a/submodules/LocationUI/Sources/LocationDistancePickerScreen.swift +++ b/submodules/LocationUI/Sources/LocationDistancePickerScreen.swift @@ -206,7 +206,7 @@ class LocationDistancePickerScreenNode: ViewControllerTracingNode, UIScrollViewD self.wrappingScrollNode.view.canCancelContentTouches = true self.dimNode = ASDisplayNode() -// self.dimNode.backgroundColor = UIColor(white: 0.0, alpha: 0.5) + self.dimNode.backgroundColor = UIColor(white: 0.0, alpha: 0.5) self.contentContainerNode = ASDisplayNode() self.contentContainerNode.isOpaque = false @@ -444,13 +444,10 @@ class LocationDistancePickerScreenNode: ViewControllerTracingNode, UIScrollViewD } func animateIn() { - self.dimNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.4) + self.dimNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3) let offset = self.bounds.size.height - self.contentBackgroundNode.frame.minY - - let dimPosition = self.dimNode.layer.position - self.dimNode.layer.animatePosition(from: CGPoint(x: dimPosition.x, y: dimPosition.y - offset), to: dimPosition, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring) - self.layer.animateBoundsOriginYAdditive(from: -offset, to: 0.0, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring) + self.wrappingScrollNode.layer.animateBoundsOriginYAdditive(from: -offset, to: 0.0, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring) } func animateOut(completion: (() -> Void)? = nil) { @@ -470,9 +467,7 @@ class LocationDistancePickerScreenNode: ViewControllerTracingNode, UIScrollViewD }) let offset = self.bounds.size.height - self.contentBackgroundNode.frame.minY - let dimPosition = self.dimNode.layer.position - self.dimNode.layer.animatePosition(from: dimPosition, to: CGPoint(x: dimPosition.x, y: dimPosition.y - offset), duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false) - self.layer.animateBoundsOriginYAdditive(from: 0.0, to: -offset, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false, completion: { _ in + self.wrappingScrollNode.layer.animateBoundsOriginYAdditive(from: 0.0, to: -offset, duration: 0.3, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false, completion: { _ in offsetCompleted = true internalCompletion() }) @@ -524,7 +519,7 @@ class LocationDistancePickerScreenNode: ViewControllerTracingNode, UIScrollViewD transition.updateFrame(node: self.effectNode, frame: CGRect(origin: CGPoint(), size: backgroundFrame.size)) transition.updateFrame(node: self.contentBackgroundNode, frame: CGRect(origin: CGPoint(), size: backgroundFrame.size)) transition.updateFrame(node: self.wrappingScrollNode, frame: CGRect(origin: CGPoint(), size: layout.size)) - transition.updateFrame(node: self.dimNode, frame: CGRect(origin: CGPoint(), size: layout.size)) + transition.updateFrame(node: self.dimNode, frame: CGRect(origin: CGPoint(), size: CGSize(width: layout.size.width, height: insets.top + 66.0 + UIScreenPixel))) let titleSize = self.titleNode.measure(CGSize(width: width, height: titleHeight)) let titleFrame = CGRect(origin: CGPoint(x: floor((contentFrame.width - titleSize.width) / 2.0), y: 16.0), size: titleSize) diff --git a/submodules/LocationUI/Sources/LocationMapNode.swift b/submodules/LocationUI/Sources/LocationMapNode.swift index e41b946416..94eedbbb70 100644 --- a/submodules/LocationUI/Sources/LocationMapNode.swift +++ b/submodules/LocationUI/Sources/LocationMapNode.swift @@ -133,7 +133,7 @@ final class LocationMapNode: ASDisplayNode, MKMapViewDelegate { var radius: Double var alpha: CGFloat { didSet { - self.alphaTransition = (oldValue, CACurrentMediaTime(), 0.3) + self.alphaTransition = (oldValue, CACurrentMediaTime(), 0.5) } } var alphaTransition: (from: CGFloat, startTimestamp: Double, duration: Double)? diff --git a/submodules/LocationUI/Sources/LocationPickerController.swift b/submodules/LocationUI/Sources/LocationPickerController.swift index 3b0c7fb075..0d9fb08ea1 100644 --- a/submodules/LocationUI/Sources/LocationPickerController.swift +++ b/submodules/LocationUI/Sources/LocationPickerController.swift @@ -103,7 +103,7 @@ public final class LocationPickerController: ViewController { }) let locationWithTimeout: (CLLocationCoordinate2D, Int32?) -> TelegramMediaMap = { coordinate, timeout in - return TelegramMediaMap(latitude: coordinate.latitude, longitude: coordinate.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: timeout) + return TelegramMediaMap(latitude: coordinate.latitude, longitude: coordinate.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: timeout, liveProximityNotificationRadius: nil) } self.interaction = LocationPickerInteraction(sendLocation: { [weak self] coordinate in @@ -168,7 +168,7 @@ public final class LocationPickerController: ViewController { } let venueType = venue.venue?.type ?? "" if ["home", "work"].contains(venueType) { - completion(TelegramMediaMap(latitude: venue.latitude, longitude: venue.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil), nil) + completion(TelegramMediaMap(latitude: venue.latitude, longitude: venue.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil), nil) } else { completion(venue, nil) } diff --git a/submodules/LocationUI/Sources/LocationPickerControllerNode.swift b/submodules/LocationUI/Sources/LocationPickerControllerNode.swift index 37854785d6..8a99b98d34 100644 --- a/submodules/LocationUI/Sources/LocationPickerControllerNode.swift +++ b/submodules/LocationUI/Sources/LocationPickerControllerNode.swift @@ -387,10 +387,10 @@ final class LocationPickerControllerNode: ViewControllerTracingNode, CLLocationM |> map { homeCoordinate, workCoordinate -> [TelegramMediaMap]? in var venues: [TelegramMediaMap] = [] if let (latitude, longitude) = homeCoordinate, let address = homeAddress { - venues.append(TelegramMediaMap(latitude: latitude, longitude: longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: presentationData.strings.Map_Home, address: address.displayString, provider: nil, id: "home", type: "home"), liveBroadcastingTimeout: nil)) + venues.append(TelegramMediaMap(latitude: latitude, longitude: longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: presentationData.strings.Map_Home, address: address.displayString, provider: nil, id: "home", type: "home"), liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil)) } if let (latitude, longitude) = workCoordinate, let address = workAddress { - venues.append(TelegramMediaMap(latitude: latitude, longitude: longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: presentationData.strings.Map_Work, address: address.displayString, provider: nil, id: "work", type: "work"), liveBroadcastingTimeout: nil)) + venues.append(TelegramMediaMap(latitude: latitude, longitude: longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: presentationData.strings.Map_Work, address: address.displayString, provider: nil, id: "work", type: "work"), liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil)) } return venues } diff --git a/submodules/LocationUI/Sources/LocationSearchContainerNode.swift b/submodules/LocationUI/Sources/LocationSearchContainerNode.swift index 4631c38a1f..2747605ef5 100644 --- a/submodules/LocationUI/Sources/LocationSearchContainerNode.swift +++ b/submodules/LocationUI/Sources/LocationSearchContainerNode.swift @@ -180,7 +180,7 @@ final class LocationSearchContainerNode: ASDisplayNode { guard let placemarkLocation = placemark.location else { continue } - let location = TelegramMediaMap(latitude: placemarkLocation.coordinate.latitude, longitude: placemarkLocation.coordinate.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil) + let location = TelegramMediaMap(latitude: placemarkLocation.coordinate.latitude, longitude: placemarkLocation.coordinate.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil) entries.append(LocationSearchEntry(index: index, theme: themeAndStrings.0, location: location, title: placemark.name ?? "Name", distance: placemarkLocation.distance(from: currentLocation))) diff --git a/submodules/LocationUI/Sources/LocationUtils.swift b/submodules/LocationUI/Sources/LocationUtils.swift index b193e255cb..37bac8d3f7 100644 --- a/submodules/LocationUI/Sources/LocationUtils.swift +++ b/submodules/LocationUI/Sources/LocationUtils.swift @@ -8,7 +8,7 @@ import MapKit extension TelegramMediaMap { convenience init(coordinate: CLLocationCoordinate2D, liveBroadcastingTimeout: Int32? = nil) { - self.init(latitude: coordinate.latitude, longitude: coordinate.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: liveBroadcastingTimeout) + self.init(latitude: coordinate.latitude, longitude: coordinate.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: liveBroadcastingTimeout, liveProximityNotificationRadius: nil) } var coordinate: CLLocationCoordinate2D { diff --git a/submodules/LocationUI/Sources/LocationViewController.swift b/submodules/LocationUI/Sources/LocationViewController.swift index 7f02874704..8ba1197c52 100644 --- a/submodules/LocationUI/Sources/LocationViewController.swift +++ b/submodules/LocationUI/Sources/LocationViewController.swift @@ -173,7 +173,8 @@ public final class LocationViewController: ViewController { if reset { if let messageId = messageId { - let _ = cancelProximityNotification(postbox: context.account.postbox, network: context.account.network, messageId: messageId).start() + +// let _ = cancelProximityNotification(postbox: context.account.postbox, network: context.account.network, messageId: messageId).start() } } else { strongSelf.controllerNode.setProximityIndicator(radius: 0) @@ -188,16 +189,10 @@ public final class LocationViewController: ViewController { return } - if let messageId = messageId { - completion() - - let _ = requestProximityNotification(postbox: context.account.postbox, network: context.account.network, messageId: messageId, distance: distance).start() - } else if let coordinate = coordinate { - strongSelf.present(textAlertController(context: strongSelf.context, title: strongSelf.presentationData.strings.Location_LiveLocationRequired_Title, text: strongSelf.presentationData.strings.Location_LiveLocationRequired_Description, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Location_LiveLocationRequired_ShareLocation, action: { [weak self] in - completion() - self?.interaction?.sendLiveLocation(coordinate, distance) - }), TextAlertAction(type: .genericAction, title: strongSelf.presentationData.strings.Common_Cancel, action: {})], actionLayout: .vertical), in: .window(.root)) + if let coordinate = coordinate { + self?.interaction?.sendLiveLocation(coordinate, distance) } + completion() }, willDismiss: { [weak self] in if let strongSelf = self { strongSelf.controllerNode.setProximityIndicator(radius: nil) @@ -235,12 +230,6 @@ public final class LocationViewController: ViewController { controller?.dismissAnimated() if let strongSelf = self { params.sendLiveLocation(TelegramMediaMap(coordinate: coordinate, liveBroadcastingTimeout: period)) - - if let distance = distance { - strongSelf.controllerNode.ownLiveLocationStartedAction = { messageId in - let _ = requestProximityNotification(postbox: context.account.postbox, network: context.account.network, messageId: messageId, distance: distance).start() - } - } } } diff --git a/submodules/LocationUI/Sources/LocationViewControllerNode.swift b/submodules/LocationUI/Sources/LocationViewControllerNode.swift index 846f32948e..524733fe55 100644 --- a/submodules/LocationUI/Sources/LocationViewControllerNode.swift +++ b/submodules/LocationUI/Sources/LocationViewControllerNode.swift @@ -302,11 +302,9 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan let selfPeer = context.account.postbox.transaction { transaction -> Peer? in return transaction.getPeer(context.account.peerId) } - - let proximityNotificationState = proximityNotificationStoredState(account: context.account, peerId: subject.id.peerId) - - self.disposable = (combineLatest(self.presentationDataPromise.get(), self.statePromise.get(), selfPeer, liveLocations, self.headerNode.mapNode.userLocation, userLocation, address, eta, proximityNotificationState) - |> deliverOnMainQueue).start(next: { [weak self] presentationData, state, selfPeer, liveLocations, userLocation, distance, address, eta, proximityNotificationState in + + self.disposable = (combineLatest(self.presentationDataPromise.get(), self.statePromise.get(), selfPeer, liveLocations, self.headerNode.mapNode.userLocation, userLocation, address, eta) + |> deliverOnMainQueue).start(next: { [weak self] presentationData, state, selfPeer, liveLocations, userLocation, distance, address, eta in if let strongSelf = self, let location = getLocation(from: subject) { var entries: [LocationViewEntry] = [] var annotations: [LocationPinAnnotation] = [] @@ -316,6 +314,7 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan let currentTime = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970) var proximityNotification: Bool? = nil + var proximityNotificationRadius: Int32? var index: Int = 0 if location.liveBroadcastingTimeout == nil { @@ -330,15 +329,14 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan for message in effectiveLiveLocations { if message.localTags.contains(.OutgoingLiveLocation) { activeOwnLiveLocation = message + if let location = getLocation(from: message), let radius = location.liveProximityNotificationRadius { + proximityNotificationRadius = radius + proximityNotification = true + } break } } - - if let activeOwnLiveLocation = activeOwnLiveLocation, let ownLiveLocationStartedAction = strongSelf.ownLiveLocationStartedAction { - strongSelf.ownLiveLocationStartedAction = nil - ownLiveLocationStartedAction(activeOwnLiveLocation.id) - } - + let title: String let subtitle: String let beginTime: Double? @@ -395,8 +393,8 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan liveBroadcastingTimeout = timeout } let remainingTime = max(0, message.timestamp + liveBroadcastingTimeout - currentTime) - if message.flags.contains(.Incoming) && remainingTime != 0 { - proximityNotification = proximityNotificationState?.distance != nil + if message.flags.contains(.Incoming) && remainingTime != 0 && proximityNotification == nil { + proximityNotification = false } let subjectLocation = CLLocation(latitude: location.latitude, longitude: location.longitude) @@ -411,8 +409,8 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan index += 1 } - if subject.id.peerId.namespace != Namespaces.Peer.CloudUser { - proximityNotification = proximityNotificationState?.distance != nil + if subject.id.peerId.namespace != Namespaces.Peer.CloudUser, proximityNotification == nil { + proximityNotification = false } let previousEntries = previousEntries.swap(entries) @@ -428,7 +426,7 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan let _ = (ApplicationSpecificNotice.getLocationProximityAlertTip(accountManager: context.sharedContext.accountManager) |> deliverOnMainQueue).start(next: { [weak self] counter in - if let strongSelf = self, counter < 3000 { + if let strongSelf = self, counter < 3 { let _ = ApplicationSpecificNotice.incrementLocationProximityAlertTip(accountManager: context.sharedContext.accountManager).start() strongSelf.displayProximityAlertTooltip() } @@ -463,7 +461,7 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan } if let _ = proximityNotification { - strongSelf.headerNode.mapNode.activeProximityRadius = (proximityNotificationState?.distance).flatMap { Double($0) } + strongSelf.headerNode.mapNode.activeProximityRadius = proximityNotificationRadius.flatMap { Double($0) } } else { strongSelf.headerNode.mapNode.activeProximityRadius = nil } @@ -611,8 +609,6 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan } } - var ownLiveLocationStartedAction: ((MessageId) -> Void)? - func showAll() { self.headerNode.mapNode.showAll() } diff --git a/submodules/PeerInfoUI/Sources/GroupInfoController.swift b/submodules/PeerInfoUI/Sources/GroupInfoController.swift index 8e74a94b0c..585ba2ecaa 100644 --- a/submodules/PeerInfoUI/Sources/GroupInfoController.swift +++ b/submodules/PeerInfoUI/Sources/GroupInfoController.swift @@ -2112,7 +2112,7 @@ public func groupInfoController(context: AccountContext, peerId originalPeerId: return } let presentationData = context.sharedContext.currentPresentationData.with { $0 } - let mapMedia = TelegramMediaMap(latitude: location.latitude, longitude: location.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), address: location.address, provider: nil, id: nil, type: nil), liveBroadcastingTimeout: nil) + let mapMedia = TelegramMediaMap(latitude: location.latitude, longitude: location.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), address: location.address, provider: nil, id: nil, type: nil), liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil) let controller = legacyLocationController(message: nil, mapMedia: mapMedia, context: context, openPeer: { _ in }, sendLiveLocation: { _, _ in }, stopLiveLocation: {}, openUrl: { url in context.sharedContext.applicationBindings.openUrl(url) }) diff --git a/submodules/ShareItems/Sources/ShareItems.swift b/submodules/ShareItems/Sources/ShareItems.swift index 53375ad1bd..0add03e2a1 100644 --- a/submodules/ShareItems/Sources/ShareItems.swift +++ b/submodules/ShareItems/Sources/ShareItems.swift @@ -260,9 +260,9 @@ private func preparedShareItem(account: Account, to peerId: PeerId, value: [Stri let disposable = TGShareLocationSignals.locationMessageContent(for: url).start(next: { value in if let value = value as? TGShareLocationResult { if let title = value.title { - subscriber.putNext(.done(.media(.media(.standalone(media: TelegramMediaMap(latitude: value.latitude, longitude: value.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: title, address: value.address, provider: value.provider, id: value.venueId, type: value.venueType), liveBroadcastingTimeout: nil)))))) + subscriber.putNext(.done(.media(.media(.standalone(media: TelegramMediaMap(latitude: value.latitude, longitude: value.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: title, address: value.address, provider: value.provider, id: value.venueId, type: value.venueType), liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil)))))) } else { - subscriber.putNext(.done(.media(.media(.standalone(media: TelegramMediaMap(latitude: value.latitude, longitude: value.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil)))))) + subscriber.putNext(.done(.media(.media(.standalone(media: TelegramMediaMap(latitude: value.latitude, longitude: value.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil)))))) } subscriber.putCompletion() } else if let value = value as? String { diff --git a/submodules/SlotMachineAnimationNode/Sources/SlotMachineAnimationNode.swift b/submodules/SlotMachineAnimationNode/Sources/SlotMachineAnimationNode.swift index 701f19c9eb..4c39a9e997 100644 --- a/submodules/SlotMachineAnimationNode/Sources/SlotMachineAnimationNode.swift +++ b/submodules/SlotMachineAnimationNode/Sources/SlotMachineAnimationNode.swift @@ -200,7 +200,7 @@ public final class SlotMachineAnimationNode: ASDisplayNode { case let .value(value, _): let slotValue = SlotMachineValue(rawValue: value) if slotValue.isThreeOfSame { - Queue.mainQueue().after(1.2) { + Queue.mainQueue().after(1.5) { self.backNode.trackTo(item: ManagedAnimationItem(source: .local("Slot_Back_Win"), loop: false)) self.success?(!slotValue.is777) } diff --git a/submodules/SyncCore/Sources/TelegramMediaMap.swift b/submodules/SyncCore/Sources/TelegramMediaMap.swift index 7d069ebfe6..3e9d71321f 100644 --- a/submodules/SyncCore/Sources/TelegramMediaMap.swift +++ b/submodules/SyncCore/Sources/TelegramMediaMap.swift @@ -133,16 +133,17 @@ public final class MapVenue: PostboxCoding, Equatable { public final class TelegramMediaMap: Media { public let latitude: Double public let longitude: Double - public let heading: Double? + public let heading: Int32? public let accuracyRadius: Double? public let geoPlace: NamedGeoPlace? public let venue: MapVenue? public let liveBroadcastingTimeout: Int32? + public let liveProximityNotificationRadius: Int32? public let id: MediaId? = nil public let peerIds: [PeerId] = [] - public init(latitude: Double, longitude: Double, heading: Double?, accuracyRadius: Double?, geoPlace: NamedGeoPlace?, venue: MapVenue?, liveBroadcastingTimeout: Int32?) { + public init(latitude: Double, longitude: Double, heading: Int32?, accuracyRadius: Double?, geoPlace: NamedGeoPlace?, venue: MapVenue?, liveBroadcastingTimeout: Int32?, liveProximityNotificationRadius: Int32?) { self.latitude = latitude self.longitude = longitude self.heading = heading @@ -150,23 +151,25 @@ public final class TelegramMediaMap: Media { self.geoPlace = geoPlace self.venue = venue self.liveBroadcastingTimeout = liveBroadcastingTimeout + self.liveProximityNotificationRadius = liveProximityNotificationRadius } public init(decoder: PostboxDecoder) { self.latitude = decoder.decodeDoubleForKey("la", orElse: 0.0) self.longitude = decoder.decodeDoubleForKey("lo", orElse: 0.0) - self.heading = decoder.decodeOptionalDoubleForKey("hdg") + self.heading = decoder.decodeOptionalInt32ForKey("hdg") self.accuracyRadius = decoder.decodeOptionalDoubleForKey("acc") self.geoPlace = decoder.decodeObjectForKey("gp", decoder: { NamedGeoPlace(decoder: $0) }) as? NamedGeoPlace self.venue = decoder.decodeObjectForKey("ve", decoder: { MapVenue(decoder: $0) }) as? MapVenue self.liveBroadcastingTimeout = decoder.decodeOptionalInt32ForKey("bt") + self.liveProximityNotificationRadius = decoder.decodeOptionalInt32ForKey("pnr") } public func encode(_ encoder: PostboxEncoder) { encoder.encodeDouble(self.latitude, forKey: "la") encoder.encodeDouble(self.longitude, forKey: "lo") if let heading = self.heading { - encoder.encodeDouble(heading, forKey: "hdg") + encoder.encodeInt32(heading, forKey: "hdg") } else { encoder.encodeNil(forKey: "hdg") } @@ -190,6 +193,11 @@ public final class TelegramMediaMap: Media { } else { encoder.encodeNil(forKey: "bt") } + if let liveProximityNotificationRadius = self.liveProximityNotificationRadius { + encoder.encodeInt32(liveProximityNotificationRadius, forKey: "pnr") + } else { + encoder.encodeNil(forKey: "pnr") + } } public func isEqual(to other: Media) -> Bool { @@ -212,6 +220,9 @@ public final class TelegramMediaMap: Media { if self.liveBroadcastingTimeout != other.liveBroadcastingTimeout { return false } + if self.liveProximityNotificationRadius != other.liveProximityNotificationRadius { + return false + } return true } return false diff --git a/submodules/TelegramApi/Sources/Api0.swift b/submodules/TelegramApi/Sources/Api0.swift index a2840ab313..06754c8514 100644 --- a/submodules/TelegramApi/Sources/Api0.swift +++ b/submodules/TelegramApi/Sources/Api0.swift @@ -373,7 +373,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-122978821] = { return Api.InputMedia.parse_inputMediaContact($0) } dict[261416433] = { return Api.InputMedia.parse_inputMediaPoll($0) } dict[-428884101] = { return Api.InputMedia.parse_inputMediaDice($0) } - dict[-1574158066] = { return Api.InputMedia.parse_inputMediaGeoLive($0) } + dict[-1759532989] = { return Api.InputMedia.parse_inputMediaGeoLive($0) } dict[2134579434] = { return Api.InputPeer.parse_inputPeerEmpty($0) } dict[2107670217] = { return Api.InputPeer.parse_inputPeerSelf($0) } dict[396093539] = { return Api.InputPeer.parse_inputPeerChat($0) } @@ -573,7 +573,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-873313984] = { return Api.MessageMedia.parse_messageMediaContact($0) } dict[1272375192] = { return Api.MessageMedia.parse_messageMediaPoll($0) } dict[1065280907] = { return Api.MessageMedia.parse_messageMediaDice($0) } - dict[-967079536] = { return Api.MessageMedia.parse_messageMediaGeoLive($0) } + dict[-1186937242] = { return Api.MessageMedia.parse_messageMediaGeoLive($0) } dict[-842892769] = { return Api.PaymentSavedCredentials.parse_paymentSavedCredentialsCard($0) } dict[1450380236] = { return Api.Null.parse_null($0) } dict[1923290508] = { return Api.auth.CodeType.parse_codeTypeSms($0) } diff --git a/submodules/TelegramApi/Sources/Api1.swift b/submodules/TelegramApi/Sources/Api1.swift index ef5d09c5d1..1dfbb974ec 100644 --- a/submodules/TelegramApi/Sources/Api1.swift +++ b/submodules/TelegramApi/Sources/Api1.swift @@ -11177,7 +11177,7 @@ public extension Api { case inputMediaContact(phoneNumber: String, firstName: String, lastName: String, vcard: String) case inputMediaPoll(flags: Int32, poll: Api.Poll, correctAnswers: [Buffer]?, solution: String?, solutionEntities: [Api.MessageEntity]?) case inputMediaDice(emoticon: String) - case inputMediaGeoLive(flags: Int32, geoPoint: Api.InputGeoPoint, heading: Int32, period: Int32?) + case inputMediaGeoLive(flags: Int32, geoPoint: Api.InputGeoPoint, heading: Int32?, period: Int32?, proximityNotificationRadius: Int32?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -11329,14 +11329,15 @@ public extension Api { } serializeString(emoticon, buffer: buffer, boxed: false) break - case .inputMediaGeoLive(let flags, let geoPoint, let heading, let period): + case .inputMediaGeoLive(let flags, let geoPoint, let heading, let period, let proximityNotificationRadius): if boxed { - buffer.appendInt32(-1574158066) + buffer.appendInt32(-1759532989) } serializeInt32(flags, buffer: buffer, boxed: false) geoPoint.serialize(buffer, true) - serializeInt32(heading, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 2) != 0 {serializeInt32(heading!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 1) != 0 {serializeInt32(period!, buffer: buffer, boxed: false)} + if Int(flags) & Int(1 << 3) != 0 {serializeInt32(proximityNotificationRadius!, buffer: buffer, boxed: false)} break } } @@ -11373,8 +11374,8 @@ public extension Api { return ("inputMediaPoll", [("flags", flags), ("poll", poll), ("correctAnswers", correctAnswers), ("solution", solution), ("solutionEntities", solutionEntities)]) case .inputMediaDice(let emoticon): return ("inputMediaDice", [("emoticon", emoticon)]) - case .inputMediaGeoLive(let flags, let geoPoint, let heading, let period): - return ("inputMediaGeoLive", [("flags", flags), ("geoPoint", geoPoint), ("heading", heading), ("period", period)]) + case .inputMediaGeoLive(let flags, let geoPoint, let heading, let period, let proximityNotificationRadius): + return ("inputMediaGeoLive", [("flags", flags), ("geoPoint", geoPoint), ("heading", heading), ("period", period), ("proximityNotificationRadius", proximityNotificationRadius)]) } } @@ -11691,15 +11692,18 @@ public extension Api { _2 = Api.parse(reader, signature: signature) as? Api.InputGeoPoint } var _3: Int32? - _3 = reader.readInt32() + if Int(_1!) & Int(1 << 2) != 0 {_3 = reader.readInt32() } var _4: Int32? if Int(_1!) & Int(1 << 1) != 0 {_4 = reader.readInt32() } + var _5: Int32? + if Int(_1!) & Int(1 << 3) != 0 {_5 = reader.readInt32() } let _c1 = _1 != nil let _c2 = _2 != nil - let _c3 = _3 != nil + let _c3 = (Int(_1!) & Int(1 << 2) == 0) || _3 != nil let _c4 = (Int(_1!) & Int(1 << 1) == 0) || _4 != nil - if _c1 && _c2 && _c3 && _c4 { - return Api.InputMedia.inputMediaGeoLive(flags: _1!, geoPoint: _2!, heading: _3!, period: _4) + let _c5 = (Int(_1!) & Int(1 << 3) == 0) || _5 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 { + return Api.InputMedia.inputMediaGeoLive(flags: _1!, geoPoint: _2!, heading: _3, period: _4, proximityNotificationRadius: _5) } else { return nil @@ -16442,7 +16446,7 @@ public extension Api { case messageMediaContact(phoneNumber: String, firstName: String, lastName: String, vcard: String, userId: Int32) case messageMediaPoll(poll: Api.Poll, results: Api.PollResults) case messageMediaDice(value: Int32, emoticon: String) - case messageMediaGeoLive(geo: Api.GeoPoint, heading: Int32, period: Int32) + case messageMediaGeoLive(flags: Int32, geo: Api.GeoPoint, heading: Int32?, period: Int32, proximityNotificationRadius: Int32?) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { switch self { @@ -16540,13 +16544,15 @@ public extension Api { serializeInt32(value, buffer: buffer, boxed: false) serializeString(emoticon, buffer: buffer, boxed: false) break - case .messageMediaGeoLive(let geo, let heading, let period): + case .messageMediaGeoLive(let flags, let geo, let heading, let period, let proximityNotificationRadius): if boxed { - buffer.appendInt32(-967079536) + buffer.appendInt32(-1186937242) } + serializeInt32(flags, buffer: buffer, boxed: false) geo.serialize(buffer, true) - serializeInt32(heading, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 0) != 0 {serializeInt32(heading!, buffer: buffer, boxed: false)} serializeInt32(period, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 1) != 0 {serializeInt32(proximityNotificationRadius!, buffer: buffer, boxed: false)} break } } @@ -16577,8 +16583,8 @@ public extension Api { return ("messageMediaPoll", [("poll", poll), ("results", results)]) case .messageMediaDice(let value, let emoticon): return ("messageMediaDice", [("value", value), ("emoticon", emoticon)]) - case .messageMediaGeoLive(let geo, let heading, let period): - return ("messageMediaGeoLive", [("geo", geo), ("heading", heading), ("period", period)]) + case .messageMediaGeoLive(let flags, let geo, let heading, let period, let proximityNotificationRadius): + return ("messageMediaGeoLive", [("flags", flags), ("geo", geo), ("heading", heading), ("period", period), ("proximityNotificationRadius", proximityNotificationRadius)]) } } @@ -16783,19 +16789,25 @@ public extension Api { } } public static func parse_messageMediaGeoLive(_ reader: BufferReader) -> MessageMedia? { - var _1: Api.GeoPoint? + var _1: Int32? + _1 = reader.readInt32() + var _2: Api.GeoPoint? if let signature = reader.readInt32() { - _1 = Api.parse(reader, signature: signature) as? Api.GeoPoint + _2 = Api.parse(reader, signature: signature) as? Api.GeoPoint } - var _2: Int32? - _2 = reader.readInt32() var _3: Int32? - _3 = reader.readInt32() + if Int(_1!) & Int(1 << 0) != 0 {_3 = reader.readInt32() } + var _4: Int32? + _4 = reader.readInt32() + var _5: Int32? + if Int(_1!) & Int(1 << 1) != 0 {_5 = reader.readInt32() } let _c1 = _1 != nil let _c2 = _2 != nil - let _c3 = _3 != nil - if _c1 && _c2 && _c3 { - return Api.MessageMedia.messageMediaGeoLive(geo: _1!, heading: _2!, period: _3!) + let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil + let _c4 = _4 != nil + let _c5 = (Int(_1!) & Int(1 << 1) == 0) || _5 != nil + if _c1 && _c2 && _c3 && _c4 && _c5 { + return Api.MessageMedia.messageMediaGeoLive(flags: _1!, geo: _2!, heading: _3, period: _4!, proximityNotificationRadius: _5) } else { return nil diff --git a/submodules/TelegramApi/Sources/Api3.swift b/submodules/TelegramApi/Sources/Api3.swift index 731f206593..73a388d40c 100644 --- a/submodules/TelegramApi/Sources/Api3.swift +++ b/submodules/TelegramApi/Sources/Api3.swift @@ -3781,23 +3781,6 @@ public extension Api { }) } - public static func requestProximityNotification(flags: Int32, peer: Api.InputPeer, msgId: Int32, maxDistance: Int32?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { - let buffer = Buffer() - buffer.appendInt32(-1322540260) - serializeInt32(flags, buffer: buffer, boxed: false) - peer.serialize(buffer, true) - serializeInt32(msgId, buffer: buffer, boxed: false) - if Int(flags) & Int(1 << 0) != 0 {serializeInt32(maxDistance!, buffer: buffer, boxed: false)} - return (FunctionDescription(name: "messages.requestProximityNotification", parameters: [("flags", flags), ("peer", peer), ("msgId", msgId), ("maxDistance", maxDistance)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in - let reader = BufferReader(buffer) - var result: Api.Bool? - if let signature = reader.readInt32() { - result = Api.parse(reader, signature: signature) as? Api.Bool - } - return result - }) - } - public static func unpinAllMessages(peer: Api.InputPeer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() buffer.appendInt32(-265962357) diff --git a/submodules/TelegramCore/Sources/AccountManager.swift b/submodules/TelegramCore/Sources/AccountManager.swift index 9721bf85ea..038a86654c 100644 --- a/submodules/TelegramCore/Sources/AccountManager.swift +++ b/submodules/TelegramCore/Sources/AccountManager.swift @@ -168,7 +168,6 @@ private var declaredEncodables: Void = { declareEncodable(Country.CountryCode.self, f: { Country.CountryCode(decoder: $0) }) declareEncodable(CountriesList.self, f: { CountriesList(decoder: $0) }) declareEncodable(ValidationMessageAttribute.self, f: { ValidationMessageAttribute(decoder: $0) }) - declareEncodable(ProximityNotificationStoredState.self, f: { ProximityNotificationStoredState(decoder: $0) }) return }() diff --git a/submodules/TelegramCore/Sources/AccountStateManagementUtils.swift b/submodules/TelegramCore/Sources/AccountStateManagementUtils.swift index 8a4e8dfe0c..28a905da2a 100644 --- a/submodules/TelegramCore/Sources/AccountStateManagementUtils.swift +++ b/submodules/TelegramCore/Sources/AccountStateManagementUtils.swift @@ -2327,14 +2327,6 @@ func replayFinalState(accountManager: AccountManager, postbox: Postbox, accountP } } } - for media in message.media { - if let action = media as? TelegramMediaAction, case .geoProximityReached = action.action { - if id.peerId.namespace == Namespaces.Peer.CloudUser { - let _ = updateProximityNotificationStoredStateInteractively(postbox: postbox, peerId: id.peerId, state: nil).start() - } - } - break - } } } } diff --git a/submodules/TelegramCore/Sources/ChatContextResult.swift b/submodules/TelegramCore/Sources/ChatContextResult.swift index 60ec1d7a1c..0f90174d46 100644 --- a/submodules/TelegramCore/Sources/ChatContextResult.swift +++ b/submodules/TelegramCore/Sources/ChatContextResult.swift @@ -424,14 +424,14 @@ extension ChatContextResultMessage { } self = .text(text: message, entities: parsedEntities, disableUrlPreview: (flags & (1 << 0)) != 0, replyMarkup: parsedReplyMarkup) case let .botInlineMessageMediaGeo(_, geo, period, replyMarkup): - let media = telegramMediaMapFromApiGeoPoint(geo, title: nil, address: nil, provider: nil, venueId: nil, venueType: nil, liveBroadcastingTimeout: period, heading: nil) + let media = telegramMediaMapFromApiGeoPoint(geo, title: nil, address: nil, provider: nil, venueId: nil, venueType: nil, liveBroadcastingTimeout: period, liveProximityNotificationRadius: nil, heading: nil) var parsedReplyMarkup: ReplyMarkupMessageAttribute? if let replyMarkup = replyMarkup { parsedReplyMarkup = ReplyMarkupMessageAttribute(apiMarkup: replyMarkup) } self = .mapLocation(media: media, replyMarkup: parsedReplyMarkup) case let .botInlineMessageMediaVenue(_, geo, title, address, provider, venueId, venueType, replyMarkup): - let media = telegramMediaMapFromApiGeoPoint(geo, title: title, address: address, provider: provider, venueId: venueId, venueType: venueType, liveBroadcastingTimeout: nil, heading: nil) + let media = telegramMediaMapFromApiGeoPoint(geo, title: title, address: address, provider: provider, venueId: venueId, venueType: venueType, liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil, heading: nil) var parsedReplyMarkup: ReplyMarkupMessageAttribute? if let replyMarkup = replyMarkup { parsedReplyMarkup = ReplyMarkupMessageAttribute(apiMarkup: replyMarkup) diff --git a/submodules/TelegramCore/Sources/PeerLiveLocationsContext.swift b/submodules/TelegramCore/Sources/PeerLiveLocationsContext.swift index 08c5c26d79..3609e85ced 100644 --- a/submodules/TelegramCore/Sources/PeerLiveLocationsContext.swift +++ b/submodules/TelegramCore/Sources/PeerLiveLocationsContext.swift @@ -32,93 +32,3 @@ public func topPeerActiveLiveLocationMessages(viewTracker: AccountViewTracker, a return (accountPeer, result) } } - -public func requestProximityNotification(postbox: Postbox, network: Network, messageId: MessageId, distance: Int32) -> Signal { - return postbox.transaction { transaction -> Api.InputPeer? in - return transaction.getPeer(messageId.peerId).flatMap(apiInputPeer) - } - |> mapToSignal { inputPeer -> Signal in - guard let inputPeer = inputPeer else { - return .complete() - } - let flags: Int32 = 1 << 0 - return network.request(Api.functions.messages.requestProximityNotification(flags: flags, peer: inputPeer, msgId: messageId.id, maxDistance: distance)) - |> map(Optional.init) - |> `catch` { _ -> Signal in - return .single(nil) - } - |> mapToSignal { _ -> Signal in - return updateProximityNotificationStoredStateInteractively(postbox: postbox, peerId: messageId.peerId, state: ProximityNotificationStoredState(messageId: messageId, distance: distance)) - } - } -} - -public func cancelProximityNotification(postbox: Postbox, network: Network, messageId: MessageId) -> Signal { - return postbox.transaction { transaction -> Api.InputPeer? in - return transaction.getPeer(messageId.peerId).flatMap(apiInputPeer) - } - |> mapToSignal { inputPeer -> Signal in - guard let inputPeer = inputPeer else { - return .complete() - } - return network.request(Api.functions.messages.requestProximityNotification(flags: 0, peer: inputPeer, msgId: messageId.id, maxDistance: nil)) - |> map(Optional.init) - |> `catch` { _ -> Signal in - return .single(nil) - } - |> mapToSignal { _ -> Signal in - return updateProximityNotificationStoredStateInteractively(postbox: postbox, peerId: messageId.peerId, state: nil) - } - } -} - -public final class ProximityNotificationStoredState: PostboxCoding { - public let messageId: MessageId - public let distance: Int32 - - public init(messageId: MessageId, distance: Int32) { - self.messageId = messageId - self.distance = distance - } - - public init(decoder: PostboxDecoder) { - self.messageId = MessageId(peerId: PeerId(decoder.decodeInt64ForKey("id.peerId", orElse: 0)), namespace: decoder.decodeInt32ForKey("id.namespace", orElse: 0), id: decoder.decodeInt32ForKey("id.id", orElse: 0)) - self.distance = decoder.decodeInt32ForKey("distance", orElse: 0) - } - - public func encode(_ encoder: PostboxEncoder) { - encoder.encodeInt64(self.messageId.peerId.toInt64(), forKey: "id.peerId") - encoder.encodeInt32(self.messageId.namespace, forKey: "id.namespace") - encoder.encodeInt32(self.messageId.id, forKey: "id.id") - encoder.encodeInt32(self.distance, forKey: "distance") - } -} - -private let collectionSpec = ItemCacheCollectionSpec(lowWaterItemCount: 25, highWaterItemCount: 50) - -public func updateProximityNotificationStoredStateInteractively(postbox: Postbox, peerId: PeerId, state: ProximityNotificationStoredState?) -> Signal { - return postbox.transaction { transaction -> Void in - let key = ValueBoxKey(length: 8) - key.setInt64(0, value: peerId.toInt64()) - let id = ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.proximityNotificationStoredState, key: key) - if let state = state { - transaction.putItemCacheEntry(id: id, entry: state, collectionSpec: collectionSpec) - } else { - transaction.removeItemCacheEntry(id: id) - } - } -} -public func proximityNotificationStoredState(account: Account, peerId: PeerId) -> Signal { - let key = ValueBoxKey(length: 8) - key.setInt64(0, value: peerId.toInt64()) - let id = ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.proximityNotificationStoredState, key: key) - let viewKey = PostboxViewKey.cachedItem(id) - return account.postbox.combinedView(keys: [viewKey]) - |> map { views -> ProximityNotificationStoredState? in - if let value = (views.views[viewKey] as? CachedItemView)?.value as? ProximityNotificationStoredState { - return value - } else { - return nil - } - } -} diff --git a/submodules/TelegramCore/Sources/PendingMessageUploadedContent.swift b/submodules/TelegramCore/Sources/PendingMessageUploadedContent.swift index e9985e09de..77f826c1fd 100644 --- a/submodules/TelegramCore/Sources/PendingMessageUploadedContent.swift +++ b/submodules/TelegramCore/Sources/PendingMessageUploadedContent.swift @@ -142,12 +142,16 @@ func mediaContentToUpload(network: Network, postbox: Postbox, auxiliaryMethods: return .single(.content(PendingMessageUploadedContentAndReuploadInfo(content: .media(input, text), reuploadInfo: nil))) } else if let map = media as? TelegramMediaMap { let input: Api.InputMedia + var flags: Int32 = 1 << 1 + if let _ = map.heading { + flags |= 1 << 2 + } var geoFlags: Int32 = 0 if let _ = map.accuracyRadius { geoFlags |= 1 << 0 } if let liveBroadcastingTimeout = map.liveBroadcastingTimeout { - input = .inputMediaGeoLive(flags: 1 << 1, geoPoint: Api.InputGeoPoint.inputGeoPoint(flags: geoFlags, lat: map.latitude, long: map.longitude, accuracyRadius: map.accuracyRadius.flatMap({ Int32($0) })), heading: 0, period: liveBroadcastingTimeout) + input = .inputMediaGeoLive(flags: flags, geoPoint: Api.InputGeoPoint.inputGeoPoint(flags: geoFlags, lat: map.latitude, long: map.longitude, accuracyRadius: map.accuracyRadius.flatMap({ Int32($0) })), heading: map.heading, period: liveBroadcastingTimeout, proximityNotificationRadius: nil) } else if let venue = map.venue { input = .inputMediaVenue(geoPoint: Api.InputGeoPoint.inputGeoPoint(flags: geoFlags, lat: map.latitude, long: map.longitude, accuracyRadius: map.accuracyRadius.flatMap({ Int32($0) })), title: venue.title, address: venue.address ?? "", provider: venue.provider ?? "", venueId: venue.id ?? "", venueType: venue.type ?? "") } else { diff --git a/submodules/TelegramCore/Sources/ProcessSecretChatIncomingDecryptedOperations.swift b/submodules/TelegramCore/Sources/ProcessSecretChatIncomingDecryptedOperations.swift index ebd7dbd8ee..ee7c56aaf5 100644 --- a/submodules/TelegramCore/Sources/ProcessSecretChatIncomingDecryptedOperations.swift +++ b/submodules/TelegramCore/Sources/ProcessSecretChatIncomingDecryptedOperations.swift @@ -794,11 +794,11 @@ private func parseMessage(peerId: PeerId, authorId: PeerId, tagLocalIndex: Int32 case let .decryptedMessageMediaWebPage(url): parsedMedia.append(TelegramMediaWebpage(webpageId: MediaId(namespace: Namespaces.Media.LocalWebpage, id: arc4random64()), content: .Pending(0, url))) case let .decryptedMessageMediaGeoPoint(lat, long): - parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil)) + parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil)) case let .decryptedMessageMediaContact(phoneNumber, firstName, lastName, userId): parsedMedia.append(TelegramMediaContact(firstName: firstName, lastName: lastName, phoneNumber: phoneNumber, peerId: userId == 0 ? nil : PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), vCardData: nil)) case let .decryptedMessageMediaVenue(lat, long, title, address, provider, venueId): - parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: title, address: address, provider: provider, id: venueId, type: nil), liveBroadcastingTimeout: nil)) + parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: title, address: address, provider: provider, id: venueId, type: nil), liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil)) case .decryptedMessageMediaEmpty: break } @@ -1013,11 +1013,11 @@ private func parseMessage(peerId: PeerId, authorId: PeerId, tagLocalIndex: Int32 case let .decryptedMessageMediaWebPage(url): parsedMedia.append(TelegramMediaWebpage(webpageId: MediaId(namespace: Namespaces.Media.LocalWebpage, id: arc4random64()), content: .Pending(0, url))) case let .decryptedMessageMediaGeoPoint(lat, long): - parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil)) + parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil)) case let .decryptedMessageMediaContact(phoneNumber, firstName, lastName, userId): parsedMedia.append(TelegramMediaContact(firstName: firstName, lastName: lastName, phoneNumber: phoneNumber, peerId: userId == 0 ? nil : PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), vCardData: nil)) case let .decryptedMessageMediaVenue(lat, long, title, address, provider, venueId): - parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: title, address: address, provider: provider, id: venueId, type: nil), liveBroadcastingTimeout: nil)) + parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: title, address: address, provider: provider, id: venueId, type: nil), liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil)) case .decryptedMessageMediaEmpty: break } @@ -1251,11 +1251,11 @@ private func parseMessage(peerId: PeerId, authorId: PeerId, tagLocalIndex: Int32 case let .decryptedMessageMediaWebPage(url): parsedMedia.append(TelegramMediaWebpage(webpageId: MediaId(namespace: Namespaces.Media.LocalWebpage, id: arc4random64()), content: .Pending(0, url))) case let .decryptedMessageMediaGeoPoint(lat, long): - parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil)) + parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil)) case let .decryptedMessageMediaContact(phoneNumber, firstName, lastName, userId): parsedMedia.append(TelegramMediaContact(firstName: firstName, lastName: lastName, phoneNumber: phoneNumber, peerId: userId == 0 ? nil : PeerId(namespace: Namespaces.Peer.CloudUser, id: userId), vCardData: nil)) case let .decryptedMessageMediaVenue(lat, long, title, address, provider, venueId): - parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: title, address: address, provider: provider, id: venueId, type: nil), liveBroadcastingTimeout: nil)) + parsedMedia.append(TelegramMediaMap(latitude: lat, longitude: long, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: title, address: address, provider: provider, id: venueId, type: nil), liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil)) case .decryptedMessageMediaEmpty: break } diff --git a/submodules/TelegramCore/Sources/RequestEditMessage.swift b/submodules/TelegramCore/Sources/RequestEditMessage.swift index 4db08c190a..d3c766231f 100644 --- a/submodules/TelegramCore/Sources/RequestEditMessage.swift +++ b/submodules/TelegramCore/Sources/RequestEditMessage.swift @@ -276,13 +276,17 @@ public func requestEditLiveLocation(postbox: Postbox, network: Network, stateMan } let inputMedia: Api.InputMedia if let coordinate = coordinate, let liveBroadcastingTimeout = media.liveBroadcastingTimeout { + var flags: Int32 = 1 << 1 + if let _ = media.heading { + flags |= 1 << 2 + } var geoFlags: Int32 = 0 if let _ = coordinate.accuracyRadius { geoFlags |= 1 << 0 } - inputMedia = .inputMediaGeoLive(flags: 1 << 1, geoPoint: .inputGeoPoint(flags: geoFlags, lat: coordinate.latitude, long: coordinate.longitude, accuracyRadius: coordinate.accuracyRadius.flatMap({ Int32($0) })), heading: heading ?? 0, period: liveBroadcastingTimeout) + inputMedia = .inputMediaGeoLive(flags: flags, geoPoint: .inputGeoPoint(flags: geoFlags, lat: coordinate.latitude, long: coordinate.longitude, accuracyRadius: coordinate.accuracyRadius.flatMap({ Int32($0) })), heading: heading, period: liveBroadcastingTimeout, proximityNotificationRadius: nil) } else { - inputMedia = .inputMediaGeoLive(flags: 1 << 0, geoPoint: .inputGeoPoint(flags: 0, lat: media.latitude, long: media.longitude, accuracyRadius: nil), heading: 0, period: nil) + inputMedia = .inputMediaGeoLive(flags: 1 << 0, geoPoint: .inputGeoPoint(flags: 0, lat: media.latitude, long: media.longitude, accuracyRadius: nil), heading: nil, period: nil, proximityNotificationRadius: nil) } return network.request(Api.functions.messages.editMessage(flags: 1 << 14, peer: inputPeer, id: messageId.id, message: nil, media: inputMedia, replyMarkup: nil, entities: nil, scheduleDate: nil)) |> map(Optional.init) diff --git a/submodules/TelegramCore/Sources/StoreMessage_Telegram.swift b/submodules/TelegramCore/Sources/StoreMessage_Telegram.swift index 114984ad82..40a13700ae 100644 --- a/submodules/TelegramCore/Sources/StoreMessage_Telegram.swift +++ b/submodules/TelegramCore/Sources/StoreMessage_Telegram.swift @@ -255,13 +255,13 @@ func textMediaAndExpirationTimerFromApiMedia(_ media: Api.MessageMedia?, _ peerI let mediaContact = TelegramMediaContact(firstName: firstName, lastName: lastName, phoneNumber: phoneNumber, peerId: contactPeerId, vCardData: vcard.isEmpty ? nil : vcard) return (mediaContact, nil) case let .messageMediaGeo(geo): - let mediaMap = telegramMediaMapFromApiGeoPoint(geo, title: nil, address: nil, provider: nil, venueId: nil, venueType: nil, liveBroadcastingTimeout: nil, heading: nil) + let mediaMap = telegramMediaMapFromApiGeoPoint(geo, title: nil, address: nil, provider: nil, venueId: nil, venueType: nil, liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil, heading: nil) return (mediaMap, nil) case let .messageMediaVenue(geo, title, address, provider, venueId, venueType): - let mediaMap = telegramMediaMapFromApiGeoPoint(geo, title: title, address: address, provider: provider, venueId: venueId, venueType: venueType, liveBroadcastingTimeout: nil, heading: nil) + let mediaMap = telegramMediaMapFromApiGeoPoint(geo, title: title, address: address, provider: provider, venueId: venueId, venueType: venueType, liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil, heading: nil) return (mediaMap, nil) - case let .messageMediaGeoLive(geo, heading, period): - let mediaMap = telegramMediaMapFromApiGeoPoint(geo, title: nil, address: nil, provider: nil, venueId: nil, venueType: nil, liveBroadcastingTimeout: period, heading: heading > 0 ? heading : nil) + case let .messageMediaGeoLive(flags, geo, heading, period, proximityNotificationRadius): + let mediaMap = telegramMediaMapFromApiGeoPoint(geo, title: nil, address: nil, provider: nil, venueId: nil, venueType: nil, liveBroadcastingTimeout: period, liveProximityNotificationRadius: proximityNotificationRadius, heading: heading) return (mediaMap, nil) case let .messageMediaDocument(_, document, ttlSeconds): if let document = document { diff --git a/submodules/TelegramCore/Sources/TelegramMediaMap.swift b/submodules/TelegramCore/Sources/TelegramMediaMap.swift index 51443d8a41..b0326ec4e4 100644 --- a/submodules/TelegramCore/Sources/TelegramMediaMap.swift +++ b/submodules/TelegramCore/Sources/TelegramMediaMap.swift @@ -4,15 +4,15 @@ import TelegramApi import SyncCore -func telegramMediaMapFromApiGeoPoint(_ geo: Api.GeoPoint, title: String?, address: String?, provider: String?, venueId: String?, venueType: String?, liveBroadcastingTimeout: Int32?, heading: Int32?) -> TelegramMediaMap { +func telegramMediaMapFromApiGeoPoint(_ geo: Api.GeoPoint, title: String?, address: String?, provider: String?, venueId: String?, venueType: String?, liveBroadcastingTimeout: Int32?, liveProximityNotificationRadius: Int32?, heading: Int32?) -> TelegramMediaMap { var venue: MapVenue? if let title = title { venue = MapVenue(title: title, address: address, provider: provider, id: venueId, type: venueType) } switch geo { case let .geoPoint(_, long, lat, _, accuracyRadius): - return TelegramMediaMap(latitude: lat, longitude: long, heading: heading.flatMap { Double($0) }, accuracyRadius: accuracyRadius.flatMap { Double($0) }, geoPlace: nil, venue: venue, liveBroadcastingTimeout: liveBroadcastingTimeout) + return TelegramMediaMap(latitude: lat, longitude: long, heading: heading, accuracyRadius: accuracyRadius.flatMap { Double($0) }, geoPlace: nil, venue: venue, liveBroadcastingTimeout: liveBroadcastingTimeout, liveProximityNotificationRadius: liveProximityNotificationRadius) case .geoPointEmpty: - return TelegramMediaMap(latitude: 0.0, longitude: 0.0, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: venue, liveBroadcastingTimeout: liveBroadcastingTimeout) + return TelegramMediaMap(latitude: 0.0, longitude: 0.0, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: venue, liveBroadcastingTimeout: liveBroadcastingTimeout, liveProximityNotificationRadius: liveProximityNotificationRadius) } } diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index f260e14b0c..bd2391d497 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -1124,7 +1124,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G |> deliverOnMainQueue).start(next: { coordinate in if let strongSelf = self { if let coordinate = coordinate { - strongSelf.sendMessages([.message(text: "", attributes: [], mediaReference: .standalone(media: TelegramMediaMap(latitude: coordinate.latitude, longitude: coordinate.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil)), replyToMessageId: nil, localGroupingKey: nil)]) + strongSelf.sendMessages([.message(text: "", attributes: [], mediaReference: .standalone(media: TelegramMediaMap(latitude: coordinate.latitude, longitude: coordinate.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil)), replyToMessageId: nil, localGroupingKey: nil)]) } else { strongSelf.present(textAlertController(context: strongSelf.context, title: nil, text: strongSelf.presentationData.strings.Login_UnknownError, actions: [TextAlertAction(type: .genericAction, title: strongSelf.presentationData.strings.Common_Cancel, action: {})]), in: .window(.root)) } diff --git a/submodules/TelegramUI/Sources/ChatMessageInteractiveFileNode.swift b/submodules/TelegramUI/Sources/ChatMessageInteractiveFileNode.swift index 93354320d1..bfe28fa2f5 100644 --- a/submodules/TelegramUI/Sources/ChatMessageInteractiveFileNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageInteractiveFileNode.swift @@ -538,7 +538,7 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode { statusFrame = statusFrameValue.offsetBy(dx: 0.0, dy: 15.0) } - if isAudio && !isVoice { + if (isAudio && !isVoice) || file.previewRepresentations.isEmpty { streamingCacheStatusFrame = CGRect(origin: CGPoint(x: progressFrame.maxX - streamingProgressDiameter + 2.0, y: progressFrame.maxY - streamingProgressDiameter + 2.0), size: CGSize(width: streamingProgressDiameter, height: streamingProgressDiameter)) } else { streamingCacheStatusFrame = CGRect() @@ -700,7 +700,7 @@ final class ChatMessageInteractiveFileNode: ASDisplayNode { selectionNode.frame = selectionFrame selectionNode.updateSelected(selection, animated: isAnimated) } else { - let selectionNode = FileMessageSelectionNode(theme: presentationData.theme.theme, incoming: incoming, isMusic: file.isMusic, toggle: { [weak self] value in + let selectionNode = FileMessageSelectionNode(theme: presentationData.theme.theme, incoming: incoming, noPreview: file.isMusic || file.previewRepresentations.isEmpty, toggle: { [weak self] value in self?.toggleSelection(value) }) strongSelf.selectionNode = selectionNode @@ -1120,12 +1120,12 @@ final class FileMessageSelectionNode: ASDisplayNode { private var selected = false private let checkNode: CheckNode - private let isMusic: Bool + private let noPreview: Bool - public init(theme: PresentationTheme, incoming: Bool, isMusic: Bool, toggle: @escaping (Bool) -> Void) { - self.isMusic = isMusic + public init(theme: PresentationTheme, incoming: Bool, noPreview: Bool, toggle: @escaping (Bool) -> Void) { + self.noPreview = noPreview self.toggle = toggle - self.checkNode = CheckNode(strokeColor: incoming ? theme.chat.message.incoming.mediaPlaceholderColor : theme.chat.message.outgoing.mediaPlaceholderColor, fillColor: theme.list.itemCheckColors.fillColor, foregroundColor: theme.list.itemCheckColors.foregroundColor, style: isMusic ? .compact : .overlay) + self.checkNode = CheckNode(strokeColor: incoming ? theme.chat.message.incoming.mediaPlaceholderColor : theme.chat.message.outgoing.mediaPlaceholderColor, fillColor: theme.list.itemCheckColors.fillColor, foregroundColor: theme.list.itemCheckColors.foregroundColor, style: noPreview ? .compact : .overlay) self.checkNode.isUserInteractionEnabled = false super.init() @@ -1169,7 +1169,7 @@ final class FileMessageSelectionNode: ASDisplayNode { let checkSize = CGSize(width: 30.0, height: 30.0) let checkOrigin: CGPoint - if self.isMusic { + if self.noPreview { checkOrigin = CGPoint(x: 23.0, y: 20.0) } else { checkOrigin = CGPoint(x: 39.0, y: -5.0) diff --git a/submodules/TelegramUI/Sources/ChatRecentActionsHistoryTransition.swift b/submodules/TelegramUI/Sources/ChatRecentActionsHistoryTransition.swift index 6249c33961..c51ea277bd 100644 --- a/submodules/TelegramUI/Sources/ChatRecentActionsHistoryTransition.swift +++ b/submodules/TelegramUI/Sources/ChatRecentActionsHistoryTransition.swift @@ -1037,7 +1037,7 @@ struct ChatRecentActionsEntry: Comparable, Identifiable { return [] }, to: &text, entities: &entities) - let mediaMap = TelegramMediaMap(latitude: updated.latitude, longitude: updated.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil) + let mediaMap = TelegramMediaMap(latitude: updated.latitude, longitude: updated.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: nil, liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil) let message = Message(stableId: self.entry.stableId, stableVersion: 0, id: MessageId(peerId: peer.id, namespace: Namespaces.Message.Cloud, id: Int32(bitPattern: self.entry.stableId)), globallyUniqueId: self.entry.event.id, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: self.entry.event.date, flags: [.Incoming], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: author, text: text, attributes: [], media: [mediaMap], peers: peers, associatedMessages: SimpleDictionary(), associatedMessageIds: []) return ChatMessageItem(presentationData: self.presentationData, context: context, chatLocation: .peer(peer.id), associatedData: ChatMessageItemAssociatedData(automaticDownloadPeerType: .channel, automaticDownloadNetworkType: .cellular, isRecentActions: true), controllerInteraction: controllerInteraction, content: .message(message: message, read: true, selection: .none, attributes: ChatMessageEntryAttributes())) diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift index ffd02fe792..17384b914b 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift @@ -3648,7 +3648,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD } let context = self.context let presentationData = self.presentationData - let mapMedia = TelegramMediaMap(latitude: location.latitude, longitude: location.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), address: location.address, provider: nil, id: nil, type: nil), liveBroadcastingTimeout: nil) + let mapMedia = TelegramMediaMap(latitude: location.latitude, longitude: location.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: MapVenue(title: peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), address: location.address, provider: nil, id: nil, type: nil), liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil) let locationController = legacyLocationController(message: nil, mapMedia: mapMedia, context: context, openPeer: { _ in }, sendLiveLocation: { _, _ in }, stopLiveLocation: {}, openUrl: { url in context.sharedContext.applicationBindings.openUrl(url) }) diff --git a/submodules/WatchBridge/Sources/WatchRequestHandlers.swift b/submodules/WatchBridge/Sources/WatchRequestHandlers.swift index 14518597f2..33c95fe481 100644 --- a/submodules/WatchBridge/Sources/WatchRequestHandlers.swift +++ b/submodules/WatchBridge/Sources/WatchRequestHandlers.swift @@ -203,7 +203,7 @@ final class WatchSendMessageHandler: WatchRequestHandler { messageSignal = .single((.message(text: args.text, attributes: [], mediaReference: nil, replyToMessageId: replyMessageId, localGroupingKey: nil), peerId)) } else if let args = subscription as? TGBridgeSendLocationMessageSubscription, let location = args.location { let peerId = makePeerIdFromBridgeIdentifier(args.peerId) - let map = TelegramMediaMap(latitude: location.latitude, longitude: location.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: makeVenue(from: location.venue), liveBroadcastingTimeout: nil) + let map = TelegramMediaMap(latitude: location.latitude, longitude: location.longitude, heading: nil, accuracyRadius: nil, geoPlace: nil, venue: makeVenue(from: location.venue), liveBroadcastingTimeout: nil, liveProximityNotificationRadius: nil) messageSignal = .single((.message(text: "", attributes: [], mediaReference: .standalone(media: map), replyToMessageId: nil, localGroupingKey: nil), peerId)) } else if let args = subscription as? TGBridgeSendStickerMessageSubscription { let peerId = makePeerIdFromBridgeIdentifier(args.peerId)