diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 0a78104a7d..88166c7015 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -8716,6 +8716,7 @@ Sorry for the inconvenience."; "AvatarEditor.SwitchToEmoji" = "SWITCH TO EMOJI"; "AvatarEditor.SwitchToStickers" = "SWITCH TO STICKERS"; "AvatarEditor.SetProfilePhoto" = "Set as Profile Photo"; +"AvatarEditor.SuggestProfilePhoto" = "Suggest as Profile Photo"; "AvatarEditor.SetGroupPhoto" = "Set as Group Photo"; "AvatarEditor.SetChannelPhoto" = "Set as Group Photo"; "AvatarEditor.Set" = "Set"; diff --git a/submodules/DrawingUI/Sources/StickerPickerScreen.swift b/submodules/DrawingUI/Sources/StickerPickerScreen.swift index 2e8458d09d..31874b73a4 100644 --- a/submodules/DrawingUI/Sources/StickerPickerScreen.swift +++ b/submodules/DrawingUI/Sources/StickerPickerScreen.swift @@ -370,6 +370,7 @@ class StickerPickerScreen: ViewController { updateScrollingToItemGroup: { [weak self] in self?.update(isExpanded: true, transition: .animated(duration: 0.4, curve: .spring)) }, + onScroll: {}, chatPeerId: nil, peekBehavior: nil, customLayout: nil, @@ -447,6 +448,7 @@ class StickerPickerScreen: ViewController { updateScrollingToItemGroup: { [weak self] in self?.update(isExpanded: true, transition: .animated(duration: 0.4, curve: .spring)) }, + onScroll: {}, chatPeerId: nil, peekBehavior: nil, customLayout: nil, @@ -571,6 +573,7 @@ class StickerPickerScreen: ViewController { updateScrollingToItemGroup: { [weak self] in self?.update(isExpanded: true, transition: .animated(duration: 0.4, curve: .spring)) }, + onScroll: {}, chatPeerId: nil, peekBehavior: stickerPeekBehavior, customLayout: nil, diff --git a/submodules/ListMessageItem/Sources/ListMessageSnippetItemNode.swift b/submodules/ListMessageItem/Sources/ListMessageSnippetItemNode.swift index 59290e7027..dc0862817c 100644 --- a/submodules/ListMessageItem/Sources/ListMessageSnippetItemNode.swift +++ b/submodules/ListMessageItem/Sources/ListMessageSnippetItemNode.swift @@ -425,7 +425,7 @@ public final class ListMessageSnippetItemNode: ListMessageNode { if messageTextUrl != rawUrlString, !item.isGlobalSearchResult { var messageText = message.text - if let translation = message.attributes.first(where: { $0 is TranslationMessageAttribute }) as? TranslationMessageAttribute, !translation.text.isEmpty, item.translateToLanguage == translation.toLang { + if !messageText.isEmpty, let translation = message.attributes.first(where: { $0 is TranslationMessageAttribute }) as? TranslationMessageAttribute, !translation.text.isEmpty, item.translateToLanguage == translation.toLang { messageText = translation.text } diff --git a/submodules/ReactionSelectionNode/Sources/ReactionContextNode.swift b/submodules/ReactionSelectionNode/Sources/ReactionContextNode.swift index 7fe625915a..c19c67ecc0 100644 --- a/submodules/ReactionSelectionNode/Sources/ReactionContextNode.swift +++ b/submodules/ReactionSelectionNode/Sources/ReactionContextNode.swift @@ -1513,6 +1513,7 @@ public final class ReactionContextNode: ASDisplayNode, UIScrollViewDelegate { }, updateScrollingToItemGroup: { }, + onScroll: {}, chatPeerId: nil, peekBehavior: nil, customLayout: emojiContentLayout, diff --git a/submodules/SaveToCameraRoll/Sources/SaveToCameraRoll.swift b/submodules/SaveToCameraRoll/Sources/SaveToCameraRoll.swift index 39636a9e70..9a5f64a162 100644 --- a/submodules/SaveToCameraRoll/Sources/SaveToCameraRoll.swift +++ b/submodules/SaveToCameraRoll/Sources/SaveToCameraRoll.swift @@ -22,7 +22,7 @@ public func fetchMediaData(context: AccountContext, postbox: Postbox, userLocati var userContentType: MediaResourceUserContentType = .other if let image = mediaReference.media as? TelegramMediaImage { userContentType = .image - if let video = image.videoRepresentations.first, forceVideo { + if let video = image.videoRepresentations.last, forceVideo { resource = video.resource isImage = false } else if let representation = largestImageRepresentation(image.representations) { diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Peers/JoinChannel.swift b/submodules/TelegramCore/Sources/TelegramEngine/Peers/JoinChannel.swift index ceff5d6fc9..2e7e672a4a 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Peers/JoinChannel.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Peers/JoinChannel.swift @@ -72,11 +72,6 @@ func _internal_joinChannel(account: Account, peerId: PeerId, hash: String?) -> S } } - if let channel = transaction.getPeer(peerId) as? TelegramChannel, case .broadcast = channel.info { - let notificationSettings = transaction.getPeerNotificationSettings(id: peerId) as? TelegramPeerNotificationSettings ?? TelegramPeerNotificationSettings.defaultSettings - transaction.updateCurrentPeerNotificationSettings([peerId: notificationSettings.withUpdatedMuteState(.muted(until: Int32.max))]) - } - return RenderedChannelParticipant(participant: updatedParticipant, peer: peer, peers: peers, presences: presences) } |> castError(JoinChannelError.self) diff --git a/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/AvatarEditorScreen.swift b/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/AvatarEditorScreen.swift index c06d04db4a..d74bdf9d59 100644 --- a/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/AvatarEditorScreen.swift +++ b/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/AvatarEditorScreen.swift @@ -581,6 +581,12 @@ final class AvatarEditorScreenComponent: Component { }, updateScrollingToItemGroup: { }, + onScroll: { [weak self] in + if let self, let state = self.state, state.expanded { + state.expanded = false + state.updated(transition: Transition(animation: .curve(duration: 0.45, curve: .spring))) + } + }, chatPeerId: nil, peekBehavior: nil, customLayout: nil, @@ -590,18 +596,6 @@ final class AvatarEditorScreenComponent: Component { hideBackground: true ) -// var stickerPeekBehavior: EmojiContentPeekBehaviorImpl? -// if let controller = self.controller { -// stickerPeekBehavior = EmojiContentPeekBehaviorImpl( -// context: controller.context, -// interaction: nil, -// chatPeerId: nil, -// present: { [weak controller] c, a in -// controller?.presentInGlobalOverlay(c, with: a) -// } -// ) -// } - data.stickers?.inputInteractionHolder.inputInteraction = EmojiPagerContentComponent.InputInteraction( performItemAction: { [weak self] _, item, _, _, _, _ in guard let self, let _ = item.itemFile else { @@ -711,6 +705,12 @@ final class AvatarEditorScreenComponent: Component { }, updateScrollingToItemGroup: { }, + onScroll: { [weak self] in + if let self, let state = self.state, state.expanded { + state.expanded = false + state.updated(transition: Transition(animation: .curve(duration: 0.45, curve: .spring))) + } + }, chatPeerId: nil, peekBehavior: nil, customLayout: nil, @@ -749,12 +749,21 @@ final class AvatarEditorScreenComponent: Component { }) self.addSubview(snapshotView) } + + if let navigationDoneButton = self.navigationDoneButton.view, !navigationDoneButton.alpha.isZero, let snapshotView = self.navigationDoneButton.view?.snapshotContentTree() { + snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false, completion: { [weak snapshotView] _ in + snapshotView?.removeFromSuperview() + }) + self.addSubview(snapshotView) + } } + let backgroundIsBright = UIColor(rgb: state.selectedBackground.colors.first ?? 0).lightness > 0.8 + let navigationCancelButtonSize = self.navigationCancelButton.update( transition: transition, component: AnyComponent(Button( - content: AnyComponent(Text(text: environment.strings.Common_Cancel, font: Font.regular(17.0), color: state.expanded ? .white : environment.theme.rootController.navigationBar.accentTextColor)), + content: AnyComponent(Text(text: environment.strings.Common_Cancel, font: Font.regular(17.0), color: state.expanded && !backgroundIsBright ? .white : environment.theme.rootController.navigationBar.accentTextColor)), action: { [weak self] in guard let self else { return @@ -776,7 +785,7 @@ final class AvatarEditorScreenComponent: Component { let navigationDoneButtonSize = self.navigationDoneButton.update( transition: transition, component: AnyComponent(Button( - content: AnyComponent(Text(text: strings.AvatarEditor_Set, font: Font.semibold(17.0), color: state.isSearchActive ? environment.theme.rootController.navigationBar.accentTextColor : .white)), + content: AnyComponent(Text(text: strings.AvatarEditor_Set, font: Font.semibold(17.0), color: state.isSearchActive || (state.expanded && backgroundIsBright) ? environment.theme.rootController.navigationBar.accentTextColor : .white)), action: { [weak self] in guard let self else { return @@ -845,8 +854,13 @@ final class AvatarEditorScreenComponent: Component { context: component.context, background: state.selectedBackground, file: state.selectedFile, - tapped: { [weak state] in + tapped: { [weak state, weak self] in if let state, !state.editingColor { + if let emojiView = self?.keyboardView.findTaggedView(tag: EmojiPagerContentComponent.Tag(id: AnyHashable("emoji"))) as? EmojiPagerContentComponent.View { + emojiView.ensureSearchUnfocused() + } else if let emojiView = self?.keyboardView.findTaggedView(tag: EmojiPagerContentComponent.Tag(id: AnyHashable("stickers"))) as? EmojiPagerContentComponent.View { + emojiView.ensureSearchUnfocused() + } state.expanded = !state.expanded state.updated(transition: Transition(animation: .curve(duration: 0.35, curve: .spring))) } @@ -1177,6 +1191,8 @@ final class AvatarEditorScreenComponent: Component { let buttonText: String switch component.peerType { + case .suggest: + buttonText = strings.AvatarEditor_SuggestProfilePhoto case .user: buttonText = strings.AvatarEditor_SetProfilePhoto case .group, .forum: @@ -1328,6 +1344,7 @@ final class AvatarEditorScreenComponent: Component { public final class AvatarEditorScreen: ViewControllerComponentContainer { public enum PeerType { + case suggest case user case group case channel diff --git a/submodules/TelegramUI/Components/ChatEntityKeyboardInputNode/Sources/ChatEntityKeyboardInputNode.swift b/submodules/TelegramUI/Components/ChatEntityKeyboardInputNode/Sources/ChatEntityKeyboardInputNode.swift index 74a7fd663b..9bc6941a75 100644 --- a/submodules/TelegramUI/Components/ChatEntityKeyboardInputNode/Sources/ChatEntityKeyboardInputNode.swift +++ b/submodules/TelegramUI/Components/ChatEntityKeyboardInputNode/Sources/ChatEntityKeyboardInputNode.swift @@ -1120,6 +1120,7 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode { }, updateScrollingToItemGroup: { }, + onScroll: {}, chatPeerId: chatPeerId, peekBehavior: stickerPeekBehavior, customLayout: nil, @@ -1390,6 +1391,7 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode { }, updateScrollingToItemGroup: { }, + onScroll: {}, chatPeerId: chatPeerId, peekBehavior: stickerPeekBehavior, customLayout: nil, @@ -2216,6 +2218,7 @@ public final class EntityInputView: UIInputView, AttachmentTextInputPanelInputVi }, updateScrollingToItemGroup: { }, + onScroll: {}, chatPeerId: nil, peekBehavior: nil, customLayout: nil, diff --git a/submodules/TelegramUI/Components/EmojiStatusSelectionComponent/Sources/EmojiStatusSelectionComponent.swift b/submodules/TelegramUI/Components/EmojiStatusSelectionComponent/Sources/EmojiStatusSelectionComponent.swift index 3505d92000..e70b7011c3 100644 --- a/submodules/TelegramUI/Components/EmojiStatusSelectionComponent/Sources/EmojiStatusSelectionComponent.swift +++ b/submodules/TelegramUI/Components/EmojiStatusSelectionComponent/Sources/EmojiStatusSelectionComponent.swift @@ -610,6 +610,7 @@ public final class EmojiStatusSelectionController: ViewController { }, updateScrollingToItemGroup: { }, + onScroll: {}, chatPeerId: nil, peekBehavior: nil, customLayout: nil, diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift index 8cd841e38d..97c6956b19 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift @@ -2249,6 +2249,7 @@ public final class EmojiPagerContentComponent: Component { public let updateSearchQuery: (EmojiPagerContentComponent.SearchQuery?) -> Void public let updateScrollingToItemGroup: () -> Void public let externalCancel: (() -> Void)? + public let onScroll: () -> Void public let chatPeerId: PeerId? public let peekBehavior: EmojiContentPeekBehavior? public let customLayout: CustomLayout? @@ -2273,6 +2274,7 @@ public final class EmojiPagerContentComponent: Component { updateSearchQuery: @escaping (SearchQuery?) -> Void, updateScrollingToItemGroup: @escaping () -> Void, externalCancel: (() -> Void)? = nil, + onScroll: @escaping () -> Void, chatPeerId: PeerId?, peekBehavior: EmojiContentPeekBehavior?, customLayout: CustomLayout?, @@ -2296,6 +2298,7 @@ public final class EmojiPagerContentComponent: Component { self.updateSearchQuery = updateSearchQuery self.updateScrollingToItemGroup = updateScrollingToItemGroup self.externalCancel = externalCancel + self.onScroll = onScroll self.chatPeerId = chatPeerId self.peekBehavior = peekBehavior self.customLayout = customLayout @@ -5045,6 +5048,15 @@ public final class EmojiPagerContentComponent: Component { } self.visibleSearchHeader?.deactivate() } + self.component?.inputInteractionHolder.inputInteraction?.onScroll() + } + + public func ensureSearchUnfocused() { + if self.isSearchActivated, let visibleSearchHeader = self.visibleSearchHeader, visibleSearchHeader.currentPresetSearchTerm == nil { + self.visibleSearchHeader?.deactivate() + } else { + self.visibleSearchHeader?.endEditing(true) + } } public func scrollViewDidScroll(_ scrollView: UIScrollView) { diff --git a/submodules/TelegramUI/Components/ForumCreateTopicScreen/Sources/ForumCreateTopicScreen.swift b/submodules/TelegramUI/Components/ForumCreateTopicScreen/Sources/ForumCreateTopicScreen.swift index e5a54028ea..586ec28d1a 100644 --- a/submodules/TelegramUI/Components/ForumCreateTopicScreen/Sources/ForumCreateTopicScreen.swift +++ b/submodules/TelegramUI/Components/ForumCreateTopicScreen/Sources/ForumCreateTopicScreen.swift @@ -969,6 +969,7 @@ private final class ForumCreateTopicScreenComponent: CombinedComponent { }, updateScrollingToItemGroup: { }, + onScroll: {}, chatPeerId: nil, peekBehavior: nil, customLayout: nil, diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index a5a12656f0..8fda5906f3 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -4673,8 +4673,16 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G threadInfo = .single(nil) } - self.peerDisposable.set((combineLatest(queue: Queue.mainQueue(), peerView.get(), onlineMemberCount, hasScheduledMessages, self.reportIrrelvantGeoNoticePromise.get(), displayedCountSignal, threadInfo) - |> deliverOnMainQueue).start(next: { [weak self] peerView, onlineMemberCount, hasScheduledMessages, peerReportNotice, pinnedCount, threadInfo in + self.peerDisposable.set(combineLatest( + queue: Queue.mainQueue(), + peerView.get(), + context.engine.data.subscribe(TelegramEngine.EngineData.Item.NotificationSettings.Global()), + onlineMemberCount, + hasScheduledMessages, + self.reportIrrelvantGeoNoticePromise.get(), + displayedCountSignal, + threadInfo + ).start(next: { [weak self] peerView, globalNotificationSettings, onlineMemberCount, hasScheduledMessages, peerReportNotice, pinnedCount, threadInfo in if let strongSelf = self { if strongSelf.peerView === peerView && strongSelf.reportIrrelvantGeoNotice == peerReportNotice && strongSelf.hasScheduledMessages == hasScheduledMessages && strongSelf.threadInfo == threadInfo { return @@ -4739,6 +4747,21 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if let notificationSettings = peerView.notificationSettings as? TelegramPeerNotificationSettings { if case let .muted(until) = notificationSettings.muteState, until >= Int32(CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970) { peerIsMuted = true + } else if case .default = notificationSettings.muteState { + if let peer = peerView.peers[peerView.peerId] { + if peer is TelegramUser { + peerIsMuted = !globalNotificationSettings.privateChats.enabled + } else if peer is TelegramGroup { + peerIsMuted = !globalNotificationSettings.groupChats.enabled + } else if let channel = peer as? TelegramChannel { + switch channel.info { + case .group: + peerIsMuted = !globalNotificationSettings.groupChats.enabled + case .broadcast: + peerIsMuted = !globalNotificationSettings.channels.enabled + } + } + } } } var peerDiscussionId: PeerId? @@ -6704,18 +6727,22 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G let isPremium = self.context.engine.data.subscribe(TelegramEngine.EngineData.Item.Peer.Peer(id: self.context.account.peerId)) |> map { peer -> Bool in return peer?.isPremium ?? false - } - self.translationStateDisposable = (combineLatest( - queue: .concurrentDefaultQueue(), - isPremium, - self.chatDisplayNode.historyNode.cachedPeerDataAndMessages - ) |> mapToSignal { isPremium, cachedDataAndMessages -> Signal in + } |> distinctUntilChanged + + let isHidden = self.chatDisplayNode.historyNode.cachedPeerDataAndMessages + |> map { cachedDataAndMessages -> Bool in let (cachedData, _) = cachedDataAndMessages var isHidden = false if let cachedData = cachedData as? CachedChannelData, cachedData.flags.contains(.translationHidden) { isHidden = true } - + return isHidden + } |> distinctUntilChanged + self.translationStateDisposable = (combineLatest( + queue: .concurrentDefaultQueue(), + isPremium, + isHidden + ) |> mapToSignal { isPremium, isHidden -> Signal in if isPremium && !isHidden { return chatTranslationState(context: context, peerId: peerId) |> map { translationState -> ChatPresentationTranslationState? in diff --git a/submodules/TelegramUI/Sources/ChatHistoryListNode.swift b/submodules/TelegramUI/Sources/ChatHistoryListNode.swift index 63f927a318..39bba905d2 100644 --- a/submodules/TelegramUI/Sources/ChatHistoryListNode.swift +++ b/submodules/TelegramUI/Sources/ChatHistoryListNode.swift @@ -2006,6 +2006,7 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode { var isTopReplyThreadMessageShownValue = false var topVisibleMessageRange: ChatTopVisibleMessageRange? let isLoading = historyView.originalView.isLoading + let translateToLanguage = transactionState.historyView.associatedData.translateToLanguage if let visible = displayedRange.visibleRange { let indexRange = (historyView.filteredEntries.count - 1 - visible.lastIndex, historyView.filteredEntries.count - 1 - visible.firstIndex) @@ -2070,6 +2071,14 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode { } } } + + if let translateToLanguage { + if let translation = message.attributes.first(where: { $0 is TranslationMessageAttribute }) as? TranslationMessageAttribute, translation.toLang == translateToLanguage { + } else if !message.text.isEmpty { + messageIdsToTranslate.append(message.id) + } + } + for media in message.media { if let _ = media as? TelegramMediaUnsupported { contentRequiredValidation = true @@ -2144,6 +2153,12 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode { } } } + if let translateToLanguage { + if let translation = message.attributes.first(where: { $0 is TranslationMessageAttribute }) as? TranslationMessageAttribute, translation.toLang == translateToLanguage { + } else if !message.text.isEmpty { + messageIdsToTranslate.append(message.id) + } + } for media in message.media { if let telegramFile = media as? TelegramMediaFile { downloadableResourceIds.append((message.id, telegramFile.resource.id.stringRepresentation)) @@ -2194,7 +2209,6 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode { } } - let translateToLanguage = transactionState.historyView.associatedData.translateToLanguage var messageIdsWithPossibleReactions: [MessageId] = [] for entry in historyView.filteredEntries { switch entry { @@ -2212,13 +2226,6 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode { default: break } - - if let translateToLanguage { - if let translation = message.attributes.first(where: { $0 is TranslationMessageAttribute }) as? TranslationMessageAttribute, translation.toLang == translateToLanguage { - } else { - messageIdsToTranslate.append(message.id) - } - } } case let .MessageGroupEntry(_, messages, _): for (message, _, _, _, _) in messages { diff --git a/submodules/TelegramUI/Sources/ChatMessageTextBubbleContentNode.swift b/submodules/TelegramUI/Sources/ChatMessageTextBubbleContentNode.swift index 96ec6c6b38..c05da71d8f 100644 --- a/submodules/TelegramUI/Sources/ChatMessageTextBubbleContentNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageTextBubbleContentNode.swift @@ -261,7 +261,7 @@ class ChatMessageTextBubbleContentNode: ChatMessageBubbleContentNode { messageEntities = updatingMedia.entities?.entities ?? [] } - if let translateToLanguage = item.associatedData.translateToLanguage { + if let translateToLanguage = item.associatedData.translateToLanguage, !item.message.text.isEmpty { isTranslating = true for attribute in item.message.attributes { if let attribute = attribute as? TranslationMessageAttribute, !attribute.text.isEmpty, attribute.toLang == translateToLanguage { diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift index 8131da8fec..f78fcacc9c 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoHeaderNode.swift @@ -2405,7 +2405,7 @@ final class PeerInfoHeaderNode: ASDisplayNode { private var currentCredibilityIcon: CredibilityIcon? private var currentPanelStatusData: PeerInfoStatusData? - func update(width: CGFloat, containerHeight: CGFloat, containerInset: CGFloat, statusBarHeight: CGFloat, navigationHeight: CGFloat, isModalOverlay: Bool, isMediaOnly: Bool, contentOffset: CGFloat, paneContainerY: CGFloat, presentationData: PresentationData, peer: Peer?, cachedData: CachedPeerData?, threadData: MessageHistoryThreadData?, notificationSettings: TelegramPeerNotificationSettings?, statusData: PeerInfoStatusData?, panelStatusData: (PeerInfoStatusData?, PeerInfoStatusData?, CGFloat?), isSecretChat: Bool, isContact: Bool, isSettings: Bool, state: PeerInfoState, metrics: LayoutMetrics, transition: ContainedViewLayoutTransition, additive: Bool) -> CGFloat { + func update(width: CGFloat, containerHeight: CGFloat, containerInset: CGFloat, statusBarHeight: CGFloat, navigationHeight: CGFloat, isModalOverlay: Bool, isMediaOnly: Bool, contentOffset: CGFloat, paneContainerY: CGFloat, presentationData: PresentationData, peer: Peer?, cachedData: CachedPeerData?, threadData: MessageHistoryThreadData?, notificationSettings: TelegramPeerNotificationSettings?, globalNotificationSettings: EngineGlobalNotificationSettings?, statusData: PeerInfoStatusData?, panelStatusData: (PeerInfoStatusData?, PeerInfoStatusData?, CGFloat?), isSecretChat: Bool, isContact: Bool, isSettings: Bool, state: PeerInfoState, metrics: LayoutMetrics, transition: ContainedViewLayoutTransition, additive: Bool) -> CGFloat { self.state = state self.peer = peer self.threadData = threadData @@ -3320,7 +3320,28 @@ final class PeerInfoHeaderNode: ASDisplayNode { } buttonIcon = .voiceChat case .mute: - if let notificationSettings = notificationSettings, case .muted = notificationSettings.muteState { + var peerIsMuted = false + if let notificationSettings { + if case .muted = notificationSettings.muteState { + peerIsMuted = true + } else if case .default = notificationSettings.muteState, let globalNotificationSettings { + if let peer { + if peer is TelegramUser { + peerIsMuted = !globalNotificationSettings.privateChats.enabled + } else if peer is TelegramGroup { + peerIsMuted = !globalNotificationSettings.groupChats.enabled + } else if let channel = peer as? TelegramChannel { + switch channel.info { + case .group: + peerIsMuted = !globalNotificationSettings.groupChats.enabled + case .broadcast: + peerIsMuted = !globalNotificationSettings.channels.enabled + } + } + } + } + } + if peerIsMuted { buttonText = presentationData.strings.PeerInfo_ButtonUnmute buttonIcon = .unmute } else { diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift index 39406f28d8..0fd23a7d61 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift @@ -7273,7 +7273,9 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate return } let peerType: AvatarEditorScreen.PeerType - if case .legacyGroup = peer { + if mode == .suggest { + peerType = .suggest + } else if case .legacyGroup = peer { peerType = .group } else if case let .channel(channel) = peer { if case .group = channel.info { @@ -8519,7 +8521,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate } let headerInset = sectionInset - var headerHeight = self.headerNode.update(width: layout.size.width, containerHeight: layout.size.height, containerInset: headerInset, statusBarHeight: layout.statusBarHeight ?? 0.0, navigationHeight: navigationHeight, isModalOverlay: layout.isModalOverlay, isMediaOnly: self.isMediaOnly, contentOffset: self.isMediaOnly ? 212.0 : self.scrollNode.view.contentOffset.y, paneContainerY: self.paneContainerNode.frame.minY, presentationData: self.presentationData, peer: self.data?.peer, cachedData: self.data?.cachedData, threadData: self.data?.threadData, notificationSettings: self.data?.notificationSettings, statusData: self.data?.status, panelStatusData: self.customStatusData, isSecretChat: self.peerId.namespace == Namespaces.Peer.SecretChat, isContact: self.data?.isContact ?? false, isSettings: self.isSettings, state: self.state, metrics: layout.metrics, transition: transition, additive: additive) + var headerHeight = self.headerNode.update(width: layout.size.width, containerHeight: layout.size.height, containerInset: headerInset, statusBarHeight: layout.statusBarHeight ?? 0.0, navigationHeight: navigationHeight, isModalOverlay: layout.isModalOverlay, isMediaOnly: self.isMediaOnly, contentOffset: self.isMediaOnly ? 212.0 : self.scrollNode.view.contentOffset.y, paneContainerY: self.paneContainerNode.frame.minY, presentationData: self.presentationData, peer: self.data?.peer, cachedData: self.data?.cachedData, threadData: self.data?.threadData, notificationSettings: self.data?.notificationSettings, globalNotificationSettings: self.data?.globalNotificationSettings, statusData: self.data?.status, panelStatusData: self.customStatusData, isSecretChat: self.peerId.namespace == Namespaces.Peer.SecretChat, isContact: self.data?.isContact ?? false, isSettings: self.isSettings, state: self.state, metrics: layout.metrics, transition: transition, additive: additive) if !self.isSettings && !self.state.isEditing { headerHeight += 71.0 } @@ -8880,7 +8882,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate } let headerInset = sectionInset - let _ = self.headerNode.update(width: layout.size.width, containerHeight: layout.size.height, containerInset: headerInset, statusBarHeight: layout.statusBarHeight ?? 0.0, navigationHeight: navigationHeight, isModalOverlay: layout.isModalOverlay, isMediaOnly: self.isMediaOnly, contentOffset: self.isMediaOnly ? 212.0 : offsetY, paneContainerY: self.paneContainerNode.frame.minY, presentationData: self.presentationData, peer: self.data?.peer, cachedData: self.data?.cachedData, threadData: self.data?.threadData, notificationSettings: self.data?.notificationSettings, statusData: self.data?.status, panelStatusData: self.customStatusData, isSecretChat: self.peerId.namespace == Namespaces.Peer.SecretChat, isContact: self.data?.isContact ?? false, isSettings: self.isSettings, state: self.state, metrics: layout.metrics, transition: transition, additive: additive) + let _ = self.headerNode.update(width: layout.size.width, containerHeight: layout.size.height, containerInset: headerInset, statusBarHeight: layout.statusBarHeight ?? 0.0, navigationHeight: navigationHeight, isModalOverlay: layout.isModalOverlay, isMediaOnly: self.isMediaOnly, contentOffset: self.isMediaOnly ? 212.0 : offsetY, paneContainerY: self.paneContainerNode.frame.minY, presentationData: self.presentationData, peer: self.data?.peer, cachedData: self.data?.cachedData, threadData: self.data?.threadData, notificationSettings: self.data?.notificationSettings, globalNotificationSettings: self.data?.globalNotificationSettings, statusData: self.data?.status, panelStatusData: self.customStatusData, isSecretChat: self.peerId.namespace == Namespaces.Peer.SecretChat, isContact: self.data?.isContact ?? false, isSettings: self.isSettings, state: self.state, metrics: layout.metrics, transition: transition, additive: additive) } let paneAreaExpansionDistance: CGFloat = 32.0 @@ -10095,7 +10097,7 @@ private final class PeerInfoNavigationTransitionNode: ASDisplayNode, CustomNavig } let headerInset = sectionInset - topHeight = self.headerNode.update(width: layout.size.width, containerHeight: layout.size.height, containerInset: headerInset, statusBarHeight: layout.statusBarHeight ?? 0.0, navigationHeight: topNavigationBar.bounds.height, isModalOverlay: layout.isModalOverlay, isMediaOnly: false, contentOffset: 0.0, paneContainerY: 0.0, presentationData: self.presentationData, peer: self.screenNode.data?.peer, cachedData: self.screenNode.data?.cachedData, threadData: self.screenNode.data?.threadData, notificationSettings: self.screenNode.data?.notificationSettings, statusData: self.screenNode.data?.status, panelStatusData: (nil, nil, nil), isSecretChat: self.screenNode.peerId.namespace == Namespaces.Peer.SecretChat, isContact: self.screenNode.data?.isContact ?? false, isSettings: self.screenNode.isSettings, state: self.screenNode.state, metrics: layout.metrics, transition: transition, additive: false) + topHeight = self.headerNode.update(width: layout.size.width, containerHeight: layout.size.height, containerInset: headerInset, statusBarHeight: layout.statusBarHeight ?? 0.0, navigationHeight: topNavigationBar.bounds.height, isModalOverlay: layout.isModalOverlay, isMediaOnly: false, contentOffset: 0.0, paneContainerY: 0.0, presentationData: self.presentationData, peer: self.screenNode.data?.peer, cachedData: self.screenNode.data?.cachedData, threadData: self.screenNode.data?.threadData, notificationSettings: self.screenNode.data?.notificationSettings, globalNotificationSettings: self.screenNode.data?.globalNotificationSettings, statusData: self.screenNode.data?.status, panelStatusData: (nil, nil, nil), isSecretChat: self.screenNode.peerId.namespace == Namespaces.Peer.SecretChat, isContact: self.screenNode.data?.isContact ?? false, isSettings: self.screenNode.isSettings, state: self.screenNode.state, metrics: layout.metrics, transition: transition, additive: false) } let titleScale = (fraction * previousTitleNode.view.bounds.height + (1.0 - fraction) * self.headerNode.titleNodeRawContainer.bounds.height) / previousTitleNode.view.bounds.height diff --git a/submodules/TranslateUI/Sources/ChatTranslation.swift b/submodules/TranslateUI/Sources/ChatTranslation.swift index 1b254eae8c..c101bddf82 100644 --- a/submodules/TranslateUI/Sources/ChatTranslation.swift +++ b/submodules/TranslateUI/Sources/ChatTranslation.swift @@ -114,7 +114,7 @@ public func translateMessageIds(context: AccountContext, messageIds: [EngineMess return context.account.postbox.transaction { transaction -> Signal in var messageIdsToTranslate: [EngineMessage.Id] = [] for messageId in messageIds { - if let message = transaction.getMessage(messageId), let translation = message.attributes.first(where: { $0 is TranslationMessageAttribute }) as? TranslationMessageAttribute, translation.toLang == toLang { + if let message = transaction.getMessage(messageId), !message.text.isEmpty, let translation = message.attributes.first(where: { $0 is TranslationMessageAttribute }) as? TranslationMessageAttribute, translation.toLang == toLang { } else { messageIdsToTranslate.append(messageId) } @@ -155,8 +155,11 @@ public func chatTranslationState(context: AccountContext, peerId: EnginePeer.Id) var fromLangs: [String: Int] = [:] var count = 0 for message in messages { + if let _ = URL(string: message.text) { + continue + } if message.text.count > 10 { - let text = String(message.text.prefix(64)) + let text = String(message.text.prefix(100)) languageRecognizer.processString(text) let hypotheses = languageRecognizer.languageHypotheses(withMaximum: 3) languageRecognizer.reset()