diff --git a/submodules/DeviceAccess/Sources/LocationManager.swift b/submodules/DeviceAccess/Sources/LocationManager.swift index f2fea873dc..99a6c39c38 100644 --- a/submodules/DeviceAccess/Sources/LocationManager.swift +++ b/submodules/DeviceAccess/Sources/LocationManager.swift @@ -33,6 +33,7 @@ public final class LocationManager: NSObject, CLLocationManagerDelegate { public func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) { if let (pendingCompletion, _) = self.pendingCompletion { pendingCompletion(status) + self.pendingCompletion = nil } } } diff --git a/submodules/LocationUI/Sources/LocationPickerControllerNode.swift b/submodules/LocationUI/Sources/LocationPickerControllerNode.swift index ced59ba714..060fd982bc 100644 --- a/submodules/LocationUI/Sources/LocationPickerControllerNode.swift +++ b/submodules/LocationUI/Sources/LocationPickerControllerNode.swift @@ -416,7 +416,7 @@ final class LocationPickerControllerNode: ViewControllerTracingNode { if let personalVenues = personalVenues { for venue in personalVenues { let venueLocation = CLLocation(latitude: venue.latitude, longitude: venue.longitude) - if venueLocation.distance(from: location) < 500 { + if venueLocation.distance(from: location) <= 1000 { resultVenues.append(venue) } } diff --git a/submodules/TelegramCore/Sources/ApplyUpdateMessage.swift b/submodules/TelegramCore/Sources/ApplyUpdateMessage.swift index 4f5e76a9eb..e399aa60cd 100644 --- a/submodules/TelegramCore/Sources/ApplyUpdateMessage.swift +++ b/submodules/TelegramCore/Sources/ApplyUpdateMessage.swift @@ -35,7 +35,7 @@ func applyUpdateMessage(postbox: Postbox, stateManager: AccountStateManager, mes var apiMessage: Api.Message? for resultMessage in result.messages { - if let id = resultMessage.id(namespace: Namespaces.Message.allScheduled.contains(message.id.namespace) ? Namespaces.Message.ScheduledCloud : Namespaces.Message.Cloud) { + if let id = resultMessage.id() { if id.peerId == message.id.peerId { apiMessage = resultMessage break @@ -43,7 +43,7 @@ func applyUpdateMessage(postbox: Postbox, stateManager: AccountStateManager, mes } } - if let apiMessage = apiMessage, let id = apiMessage.id(namespace: message.scheduleTime != nil && message.scheduleTime == apiMessage.timestamp ? Namespaces.Message.ScheduledCloud : Namespaces.Message.Cloud) { + if let apiMessage = apiMessage, let id = apiMessage.id() { messageId = id.id } else { messageId = result.rawMessageIds.first @@ -80,7 +80,14 @@ func applyUpdateMessage(postbox: Postbox, stateManager: AccountStateManager, mes transaction.updateMessage(message.id, update: { currentMessage in let updatedId: MessageId if let messageId = messageId { - let namespace = Namespaces.Message.allScheduled.contains(message.id.namespace) ? Namespaces.Message.ScheduledCloud : Namespaces.Message.Cloud + var namespace: MessageId.Namespace = Namespaces.Message.Cloud + if let updatedTimestamp = updatedTimestamp { + if message.scheduleTime != nil && message.scheduleTime == updatedTimestamp { + namespace = Namespaces.Message.ScheduledCloud + } + } else if Namespaces.Message.allScheduled.contains(message.id.namespace) { + namespace = Namespaces.Message.ScheduledCloud + } updatedId = MessageId(peerId: currentMessage.id.peerId, namespace: namespace, id: messageId) } else { updatedId = currentMessage.id @@ -114,6 +121,15 @@ func applyUpdateMessage(postbox: Postbox, stateManager: AccountStateManager, mes updatedAttributes.append(TextEntitiesMessageAttribute(entities: messageTextEntitiesFromApiEntities(entities))) } + if Namespaces.Message.allScheduled.contains(message.id.namespace) && updatedId.namespace == Namespaces.Message.Cloud { + for i in 0 ..< updatedAttributes.count { + if updatedAttributes[i] is OutgoingScheduleInfoMessageAttribute { + updatedAttributes.remove(at: i) + break + } + } + } + attributes = updatedAttributes text = currentMessage.text diff --git a/submodules/TelegramCore/Sources/EnqueueMessage.swift b/submodules/TelegramCore/Sources/EnqueueMessage.swift index 75479694bb..7270409540 100644 --- a/submodules/TelegramCore/Sources/EnqueueMessage.swift +++ b/submodules/TelegramCore/Sources/EnqueueMessage.swift @@ -380,7 +380,6 @@ func enqueueMessages(transaction: Transaction, account: Account, peerId: PeerId, for attribute in attributes { if let attribute = attribute as? OutgoingScheduleInfoMessageAttribute { if attribute.scheduleTime == scheduleWhenOnlineTimestamp, let presence = peerPresence as? TelegramUserPresence, case let .present(statusTimestamp) = presence.status, statusTimestamp >= timestamp { - } else { messageNamespace = Namespaces.Message.ScheduledLocal effectiveTimestamp = attribute.scheduleTime @@ -526,7 +525,6 @@ func enqueueMessages(transaction: Transaction, account: Account, peerId: PeerId, } if let attribute = attribute as? OutgoingScheduleInfoMessageAttribute { if attribute.scheduleTime == scheduleWhenOnlineTimestamp, let presence = peerPresence as? TelegramUserPresence, case let .present(statusTimestamp) = presence.status, statusTimestamp >= timestamp { - } else { messageNamespace = Namespaces.Message.ScheduledLocal effectiveTimestamp = attribute.scheduleTime diff --git a/submodules/TelegramUIPreferences/Sources/IntentsSettings.swift b/submodules/TelegramUIPreferences/Sources/IntentsSettings.swift index 71d2c427fa..aeebdbe011 100644 --- a/submodules/TelegramUIPreferences/Sources/IntentsSettings.swift +++ b/submodules/TelegramUIPreferences/Sources/IntentsSettings.swift @@ -27,7 +27,7 @@ public struct IntentsSettings: PreferencesEntry, Equatable { } public init(decoder: PostboxDecoder) { - self.initiallyReset = decoder.decodeBoolForKey("initiallyReset", orElse: false) + self.initiallyReset = decoder.decodeBoolForKey("initiallyReset_v2", orElse: false) self.account = decoder.decodeOptionalInt64ForKey("account").flatMap { PeerId($0) } self.contacts = decoder.decodeBoolForKey("contacts", orElse: true) self.privateChats = decoder.decodeBoolForKey("privateChats", orElse: false) @@ -37,7 +37,7 @@ public struct IntentsSettings: PreferencesEntry, Equatable { } public func encode(_ encoder: PostboxEncoder) { - encoder.encodeBool(self.initiallyReset, forKey: "initiallyReset") + encoder.encodeBool(self.initiallyReset, forKey: "initiallyReset_v2") if let account = self.account { encoder.encodeInt64(account.toInt64(), forKey: "account") } else {