diff --git a/Makefile b/Makefile index 77a0ce04ca..2e6385ffbe 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ include Utils.makefile -APP_VERSION="7.1.2" +APP_VERSION="7.2" CORE_COUNT=$(shell sysctl -n hw.logicalcpu) CORE_COUNT_MINUS_ONE=$(shell expr ${CORE_COUNT} \- 1) diff --git a/Telegram/Watch/App/Base.lproj/Interface.storyboard b/Telegram/Watch/App/Base.lproj/Interface.storyboard index dc860eb1cc..1aba2ec72a 100644 --- a/Telegram/Watch/App/Base.lproj/Interface.storyboard +++ b/Telegram/Watch/App/Base.lproj/Interface.storyboard @@ -1,12 +1,9 @@ - - - - + + - - - + + @@ -1097,432 +1094,6 @@ contacts found. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2000,4 +1571,20 @@ contacts found. + + + + + + + + + + + + + + + + diff --git a/Telegram/Watch/Extension/TGWatchColor.m b/Telegram/Watch/Extension/TGWatchColor.m index fcbf7d1776..afc4a7e960 100644 --- a/Telegram/Watch/Extension/TGWatchColor.m +++ b/Telegram/Watch/Extension/TGWatchColor.m @@ -38,7 +38,7 @@ + (UIColor *)colorForUserId:(int32_t)userId myUserId:(int32_t)myUserId { - return [self placeholderColors][userId % 7]; + return [self placeholderColors][abs(userId) % 7]; } + (UIColor *)colorForGroupId:(int64_t)groupId diff --git a/build-system/generate-xcode-project.sh b/build-system/generate-xcode-project.sh index fb4dc01612..9910f9d3b9 100755 --- a/build-system/generate-xcode-project.sh +++ b/build-system/generate-xcode-project.sh @@ -54,9 +54,11 @@ BAZEL_OPTIONS=(\ --swiftcopt=-j${CORE_COUNT_MINUS_ONE} \ ) -if [ "$BAZEL_CACHE_DIR" != "" ]; then +if [ "$BAZEL_HTTP_CACHE_URL" != "" ]; then + BAZEL_OPTIONS=("${BAZEL_OPTIONS[@]}" --remote_cache="$(echo $BAZEL_HTTP_CACHE_URL | sed -e 's/[\/&]/\\&/g')") +elif [ "$BAZEL_CACHE_DIR" != "" ]; then BAZEL_OPTIONS=("${BAZEL_OPTIONS[@]}" --disk_cache="$(echo $BAZEL_CACHE_DIR | sed -e 's/[\/&]/\\&/g')") -fi +fi "$TULSI" -- \ --verbose \ diff --git a/submodules/ChatListUI/Sources/Node/ChatListItem.swift b/submodules/ChatListUI/Sources/Node/ChatListItem.swift index cf1a78d25f..d64ede01c7 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListItem.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListItem.swift @@ -795,7 +795,13 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { } embeddedState = embeddedStateValue summaryInfo = summaryInfoValue - inputActivities = inputActivitiesValue + + if let peerPresence = peerPresence as? TelegramUserPresence, case .present = peerPresence.status { + inputActivities = inputActivitiesValue + } else { + inputActivities = nil + } + isPeerGroup = false promoInfo = promoInfoValue displayAsMessage = displayAsMessageValue @@ -1320,6 +1326,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode { var inputActivitiesSize: CGSize? var inputActivitiesApply: (() -> Void)? if let inputActivities = inputActivities, !inputActivities.isEmpty { + let (size, apply) = inputActivitiesLayout(CGSize(width: rawContentWidth - badgeSize, height: 40.0), item.presentationData, item.presentationData.theme.chatList.messageTextColor, item.index.messageIndex.id.peerId, inputActivities) inputActivitiesSize = size inputActivitiesApply = apply diff --git a/submodules/TelegramCore/Sources/HistoryViewStateValidation.swift b/submodules/TelegramCore/Sources/HistoryViewStateValidation.swift index 3a08b937fe..5e570a1b8e 100644 --- a/submodules/TelegramCore/Sources/HistoryViewStateValidation.swift +++ b/submodules/TelegramCore/Sources/HistoryViewStateValidation.swift @@ -416,6 +416,9 @@ private func hashForMessages(_ messages: [Message], withChannelIds: Bool) -> Int break inner } } + if message.tags.contains(.pinned) { + acc = (acc &* 20261) &+ UInt32(1) + } acc = (acc &* 20261) &+ UInt32(timestamp) } return Int32(bitPattern: acc & UInt32(0x7FFFFFFF)) diff --git a/submodules/TelegramCore/Sources/ManagedLocalInputActivities.swift b/submodules/TelegramCore/Sources/ManagedLocalInputActivities.swift index b8ace47668..2f435c6c29 100644 --- a/submodules/TelegramCore/Sources/ManagedLocalInputActivities.swift +++ b/submodules/TelegramCore/Sources/ManagedLocalInputActivities.swift @@ -139,7 +139,7 @@ private func requestActivity(postbox: Postbox, network: Network, accountPeerId: break case let .present(statusTimestamp): let timestamp = Int32(CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970) - if statusTimestamp < timestamp { + if statusTimestamp < timestamp - 30 { return .complete() } } diff --git a/submodules/TelegramNotices/Sources/Notices.swift b/submodules/TelegramNotices/Sources/Notices.swift index 0d6aeeee83..01b4e7b6b4 100644 --- a/submodules/TelegramNotices/Sources/Notices.swift +++ b/submodules/TelegramNotices/Sources/Notices.swift @@ -302,6 +302,32 @@ public struct ApplicationSpecificNotice { } } + public static func inlineBotLocationRequestStatus(accountManager: AccountManager, peerId: PeerId) -> Signal { + return accountManager.noticeEntry(key: ApplicationSpecificNoticeKeys.inlineBotLocationRequestNotice(peerId: peerId)) + |> map { view -> Bool in + guard let value = view.value as? ApplicationSpecificTimestampNotice else { + return false + } + if value.value == 0 { + return true + } else { + return false + } + } + } + + public static func updateInlineBotLocationRequestState(accountManager: AccountManager, peerId: PeerId, timestamp: Int32) -> Signal { + return accountManager.transaction { transaction -> Bool in + if let notice = transaction.getNotice(ApplicationSpecificNoticeKeys.inlineBotLocationRequestNotice(peerId: peerId)) as? ApplicationSpecificTimestampNotice, (notice.value == 0 || timestamp <= notice.value + 10 * 60) { + return false + } + + transaction.setNotice(ApplicationSpecificNoticeKeys.inlineBotLocationRequestNotice(peerId: peerId), ApplicationSpecificTimestampNotice(value: timestamp)) + + return true + } + } + public static func setInlineBotLocationRequest(accountManager: AccountManager, peerId: PeerId, value: Int32) -> Signal { return accountManager.transaction { transaction -> Void in transaction.setNotice(ApplicationSpecificNoticeKeys.inlineBotLocationRequestNotice(peerId: peerId), ApplicationSpecificTimestampNotice(value: value)) diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index f74d6526a9..9a4318b5cc 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -6568,7 +6568,21 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G let inputTextPanelState = inputTextPanelStateForChatPresentationInterfaceState(temporaryChatPresentationInterfaceState, context: self.context) var updatedChatPresentationInterfaceState = temporaryChatPresentationInterfaceState.updatedInputTextPanelState({ _ in return inputTextPanelState }) - let contextQueryUpdates = contextQueryResultStateForChatInterfacePresentationState(updatedChatPresentationInterfaceState, context: self.context, currentQueryStates: &self.contextQueryStates) + let contextQueryUpdates = contextQueryResultStateForChatInterfacePresentationState(updatedChatPresentationInterfaceState, context: self.context, currentQueryStates: &self.contextQueryStates, requestBotLocationStatus: { [weak self] peerId in + guard let strongSelf = self else { + return + } + let _ = (ApplicationSpecificNotice.updateInlineBotLocationRequestState(accountManager: strongSelf.context.sharedContext.accountManager, peerId: peerId, timestamp: Int32(Date().timeIntervalSince1970 + 10 * 60)) + |> deliverOnMainQueue).start(next: { value in + guard let strongSelf = self, value else { + return + } + strongSelf.present(textAlertController(context: strongSelf.context, title: nil, text: strongSelf.presentationData.strings.Conversation_ShareInlineBotLocationConfirmation, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_Cancel, action: { + }), TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: { + let _ = ApplicationSpecificNotice.setInlineBotLocationRequest(accountManager: strongSelf.context.sharedContext.accountManager, peerId: peerId, value: 0).start() + })]), in: .window(.root)) + }) + }) for (kind, update) in contextQueryUpdates { switch update { diff --git a/submodules/TelegramUI/Sources/ChatInterfaceStateContextQueries.swift b/submodules/TelegramUI/Sources/ChatInterfaceStateContextQueries.swift index f3b0b519de..da43b326b2 100644 --- a/submodules/TelegramUI/Sources/ChatInterfaceStateContextQueries.swift +++ b/submodules/TelegramUI/Sources/ChatInterfaceStateContextQueries.swift @@ -11,6 +11,7 @@ import AccountContext import Emoji import SearchPeerMembers import DeviceLocationManager +import TelegramNotices enum ChatContextQueryError { case inlineBotLocationRequest(PeerId) @@ -21,7 +22,7 @@ enum ChatContextQueryUpdate { case update(ChatPresentationInputQuery, Signal<(ChatPresentationInputQueryResult?) -> ChatPresentationInputQueryResult?, ChatContextQueryError>) } -func contextQueryResultStateForChatInterfacePresentationState(_ chatPresentationInterfaceState: ChatPresentationInterfaceState, context: AccountContext, currentQueryStates: inout [ChatPresentationInputQueryKind: (ChatPresentationInputQuery, Disposable)]) -> [ChatPresentationInputQueryKind: ChatContextQueryUpdate] { +func contextQueryResultStateForChatInterfacePresentationState(_ chatPresentationInterfaceState: ChatPresentationInterfaceState, context: AccountContext, currentQueryStates: inout [ChatPresentationInputQueryKind: (ChatPresentationInputQuery, Disposable)], requestBotLocationStatus: @escaping (PeerId) -> Void) -> [ChatPresentationInputQueryKind: ChatContextQueryUpdate] { guard let peer = chatPresentationInterfaceState.renderedPeer?.peer else { return [:] } @@ -43,7 +44,7 @@ func contextQueryResultStateForChatInterfacePresentationState(_ chatPresentation for query in inputQueries { let previousQuery = currentQueryStates[query.kind]?.0 if previousQuery != query { - let signal = updatedContextQueryResultStateForQuery(context: context, peer: peer, chatLocation: chatPresentationInterfaceState.chatLocation, inputQuery: query, previousQuery: previousQuery) + let signal = updatedContextQueryResultStateForQuery(context: context, peer: peer, chatLocation: chatPresentationInterfaceState.chatLocation, inputQuery: query, previousQuery: previousQuery, requestBotLocationStatus: requestBotLocationStatus) updates[query.kind] = .update(query, signal) } } @@ -64,7 +65,7 @@ func contextQueryResultStateForChatInterfacePresentationState(_ chatPresentation return updates } -private func updatedContextQueryResultStateForQuery(context: AccountContext, peer: Peer, chatLocation: ChatLocation, inputQuery: ChatPresentationInputQuery, previousQuery: ChatPresentationInputQuery?) -> Signal<(ChatPresentationInputQueryResult?) -> ChatPresentationInputQueryResult?, ChatContextQueryError> { +private func updatedContextQueryResultStateForQuery(context: AccountContext, peer: Peer, chatLocation: ChatLocation, inputQuery: ChatPresentationInputQuery, previousQuery: ChatPresentationInputQuery?, requestBotLocationStatus: @escaping (PeerId) -> Void) -> Signal<(ChatPresentationInputQueryResult?) -> ChatPresentationInputQueryResult?, ChatContextQueryError> { switch inputQuery { case let .emoji(query): var signal: Signal<(ChatPresentationInputQueryResult?) -> ChatPresentationInputQueryResult?, ChatContextQueryError> = .complete() @@ -245,10 +246,21 @@ private func updatedContextQueryResultStateForQuery(context: AccountContext, pee |> castError(ChatContextQueryError.self) |> mapToSignal { peer -> Signal<(ChatPresentationInputQueryResult?) -> ChatPresentationInputQueryResult?, ChatContextQueryError> in if let user = peer as? TelegramUser, let botInfo = user.botInfo, let _ = botInfo.inlinePlaceholder { - let contextResults = requestChatContextResults(account: context.account, botId: user.id, peerId: chatPeer.id, query: query, location: context.sharedContext.locationManager.flatMap { locationManager in - return currentLocationManagerCoordinate(manager: locationManager, timeout: 5.0) - |> flatMap { coordinate -> (Double, Double) in - return (coordinate.latitude, coordinate.longitude) + let contextResults = requestChatContextResults(account: context.account, botId: user.id, peerId: chatPeer.id, query: query, location: context.sharedContext.locationManager.flatMap { locationManager -> Signal<(Double, Double)?, NoError> in + return `deferred` { + Queue.mainQueue().async { + requestBotLocationStatus(user.id) + } + + return ApplicationSpecificNotice.inlineBotLocationRequestStatus(accountManager: context.sharedContext.accountManager, peerId: user.id) + |> filter { $0 } + |> take(1) + |> mapToSignal { _ -> Signal<(Double, Double)?, NoError> in + return currentLocationManagerCoordinate(manager: locationManager, timeout: 5.0) + |> flatMap { coordinate -> (Double, Double) in + return (coordinate.latitude, coordinate.longitude) + } + } } } ?? .single(nil), offset: "") |> mapError { error -> ChatContextQueryError in diff --git a/submodules/TelegramUI/Sources/WidgetDataContext.swift b/submodules/TelegramUI/Sources/WidgetDataContext.swift index c3b59ac91b..37334f64e2 100644 --- a/submodules/TelegramUI/Sources/WidgetDataContext.swift +++ b/submodules/TelegramUI/Sources/WidgetDataContext.swift @@ -61,7 +61,9 @@ final class WidgetDataContext { } if #available(iOSApplicationExtension 14.0, iOS 14.0, *) { + #if arch(arm64) || arch(i386) || arch(x86_64) WidgetCenter.shared.reloadAllTimelines() + #endif } }) @@ -78,7 +80,9 @@ final class WidgetDataContext { } if #available(iOSApplicationExtension 14.0, iOS 14.0, *) { + #if arch(arm64) || arch(i386) || arch(x86_64) WidgetCenter.shared.reloadAllTimelines() + #endif } })