diff --git a/submodules/ComponentFlow/Source/Base/Transition.swift b/submodules/ComponentFlow/Source/Base/Transition.swift index 5bf0b3954f..4fa4a7aada 100644 --- a/submodules/ComponentFlow/Source/Base/Transition.swift +++ b/submodules/ComponentFlow/Source/Base/Transition.swift @@ -299,7 +299,7 @@ public struct Transition { } } - public func attachAnimation(view: UIView, completion: @escaping (Bool) -> Void) { + public func attachAnimation(view: UIView, id: String, completion: @escaping (Bool) -> Void) { switch self.animation { case .none: completion(true) @@ -307,7 +307,7 @@ public struct Transition { view.layer.animate( from: 0.0 as NSNumber, to: 1.0 as NSNumber, - keyPath: "attached\(UInt32.random(in: 0 ... UInt32.max))", + keyPath: id, duration: duration, delay: 0.0, curve: curve, diff --git a/submodules/FeaturedStickersScreen/Sources/FeaturedStickersScreen.swift b/submodules/FeaturedStickersScreen/Sources/FeaturedStickersScreen.swift index 94985ccb08..128cb9700a 100644 --- a/submodules/FeaturedStickersScreen/Sources/FeaturedStickersScreen.swift +++ b/submodules/FeaturedStickersScreen/Sources/FeaturedStickersScreen.swift @@ -1205,7 +1205,7 @@ private final class FeaturedPaneSearchContentNode: ASDisplayNode { let query = text.trimmingCharacters(in: .whitespacesAndNewlines) if query.isSingleEmoji { signals = .single([context.engine.stickers.searchStickers(query: text.basicEmoji.0) - |> map { (nil, $0) }]) + |> map { (nil, $0.items) }]) } else if query.count > 1, let languageCode = languageCode, !languageCode.isEmpty && languageCode != "emoji" { var signal = context.engine.stickers.searchEmojiKeywords(inputLanguageCode: languageCode, query: query.lowercased(), completeMatch: query.count < 3) if !languageCode.lowercased().hasPrefix("en") { @@ -1228,7 +1228,7 @@ private final class FeaturedPaneSearchContentNode: ASDisplayNode { for emoji in emoticons { signals.append(context.engine.stickers.searchStickers(query: emoji.basicEmoji.0) |> take(1) - |> map { (emoji, $0) }) + |> map { (emoji, $0.items) }) } return signals } diff --git a/submodules/PeerInfoUI/Sources/ChannelPermissionsController.swift b/submodules/PeerInfoUI/Sources/ChannelPermissionsController.swift index 10bd87f989..f58b2dbf94 100644 --- a/submodules/PeerInfoUI/Sources/ChannelPermissionsController.swift +++ b/submodules/PeerInfoUI/Sources/ChannelPermissionsController.swift @@ -523,12 +523,12 @@ let publicGroupRestrictedPermissions: TelegramChatBannedRightsFlags = [ ] func groupPermissionDependencies(_ right: TelegramChatBannedRightsFlags) -> TelegramChatBannedRightsFlags { - if right.contains(.banSendMedia) || banSendMediaSubList().contains(where: { $0.0 == right }) { + if right.contains(.banEmbedLinks) { + return [.banSendText] + } else if right.contains(.banSendMedia) || banSendMediaSubList().contains(where: { $0.0 == right }) { return [] } else if right.contains(.banSendGifs) { return [] - } else if right.contains(.banEmbedLinks) { - return [] } else if right.contains(.banSendPolls) { return [] } else if right.contains(.banChangeInfo) { @@ -762,6 +762,11 @@ public func channelPermissionsController(context: AccountContext, updatedPresent effectiveRightsFlags.insert(right) } } + for (right, _) in banSendMediaSubList() { + if groupPermissionDependencies(right).contains(rights) { + effectiveRightsFlags.insert(right) + } + } } } if banSendMediaSubList().allSatisfy({ !effectiveRightsFlags.contains($0.0) }) { diff --git a/submodules/TelegramCore/Sources/ApiUtils/TelegramGroup.swift b/submodules/TelegramCore/Sources/ApiUtils/TelegramGroup.swift index b06f2ed5e9..912d167749 100644 --- a/submodules/TelegramCore/Sources/ApiUtils/TelegramGroup.swift +++ b/submodules/TelegramCore/Sources/ApiUtils/TelegramGroup.swift @@ -7,16 +7,42 @@ private final class LinkHelperClass: NSObject { } public extension TelegramGroup { + enum Permission { + case sendSomething + } + + func hasPermission(_ permission: Permission) -> Bool { + switch permission { + case .sendSomething: + let flags: TelegramChatBannedRightsFlags = [ + .banSendText, + .banSendInstantVideos, + .banSendVoice, + .banSendPhotos, + .banSendVideos, + .banSendStickers, + .banSendPolls, + .banSendFiles, + .banSendInline + ] + + if let defaultBannedRights = self.defaultBannedRights, defaultBannedRights.flags.intersection(flags) == flags { + return false + } + return true + } + } + func hasBannedPermission(_ rights: TelegramChatBannedRightsFlags) -> Bool { switch self.role { - case .creator, .admin: + case .creator, .admin: + return false + default: + if let bannedRights = self.defaultBannedRights { + return bannedRights.flags.contains(rights) + } else { return false - default: - if let bannedRights = self.defaultBannedRights { - return bannedRights.flags.contains(rights) - } else { - return false - } + } } } } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Stickers/SearchStickers.swift b/submodules/TelegramCore/Sources/TelegramEngine/Stickers/SearchStickers.swift index 187871d5d4..ba83cc602e 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Stickers/SearchStickers.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Stickers/SearchStickers.swift @@ -81,9 +81,9 @@ func _internal_randomGreetingSticker(account: Account) -> Signal Signal<[FoundStickerItem], NoError> { +func _internal_searchStickers(account: Account, query: String, scope: SearchStickersScope = [.installed, .remote]) -> Signal<(items: [FoundStickerItem], isFinalResult: Bool), NoError> { if scope.isEmpty { - return .single([]) + return .single(([], true)) } var query = query if query == "\u{2764}" { @@ -203,9 +203,10 @@ func _internal_searchStickers(account: Account, query: String, scope: SearchStic } return (result, cached, isPremium, searchStickersConfiguration) - } |> mapToSignal { localItems, cached, isPremium, searchStickersConfiguration -> Signal<[FoundStickerItem], NoError> in + } + |> mapToSignal { localItems, cached, isPremium, searchStickersConfiguration -> Signal<(items: [FoundStickerItem], isFinalResult: Bool), NoError> in if !scope.contains(.remote) { - return .single(localItems) + return .single((localItems, true)) } var tempResult: [FoundStickerItem] = [] @@ -281,8 +282,8 @@ func _internal_searchStickers(account: Account, query: String, scope: SearchStic |> `catch` { _ -> Signal in return .single(.stickersNotModified) } - |> mapToSignal { result -> Signal<[FoundStickerItem], NoError> in - return account.postbox.transaction { transaction -> [FoundStickerItem] in + |> mapToSignal { result -> Signal<(items: [FoundStickerItem], isFinalResult: Bool), NoError> in + return account.postbox.transaction { transaction -> (items: [FoundStickerItem], isFinalResult: Bool) in switch result { case let .stickers(hash, stickers): var result: [FoundStickerItem] = [] @@ -358,14 +359,14 @@ func _internal_searchStickers(account: Account, query: String, scope: SearchStic transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerQueryResults, key: CachedStickerQueryResult.cacheKey(query)), entry: entry) } - return result + return (result, true) case .stickersNotModified: break } - return tempResult + return (tempResult, true) } } - return .single(tempResult) + return .single((tempResult, false)) |> then(remote) } } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Stickers/TelegramEngineStickers.swift b/submodules/TelegramCore/Sources/TelegramEngine/Stickers/TelegramEngineStickers.swift index 52aa9951ed..2b4a9a136a 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Stickers/TelegramEngineStickers.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Stickers/TelegramEngineStickers.swift @@ -30,7 +30,7 @@ public extension TelegramEngine { return _internal_randomGreetingSticker(account: self.account) } - public func searchStickers(query: String, scope: SearchStickersScope = [.installed, .remote]) -> Signal<[FoundStickerItem], NoError> { + public func searchStickers(query: String, scope: SearchStickersScope = [.installed, .remote]) -> Signal<(items: [FoundStickerItem], isFinalResult: Bool), NoError> { return _internal_searchStickers(account: self.account, query: query, scope: scope) } diff --git a/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/AvatarEditorScreen.swift b/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/AvatarEditorScreen.swift index 1d46b95b1e..d2af96c28a 100644 --- a/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/AvatarEditorScreen.swift +++ b/submodules/TelegramUI/Components/AvatarEditorScreen/Sources/AvatarEditorScreen.swift @@ -281,7 +281,11 @@ final class AvatarEditorScreenComponent: Component { |> mapToSignal { keywords -> Signal<[EmojiPagerContentComponent.ItemGroup], NoError> in return combineLatest( context.account.postbox.itemCollectionsView(orderedItemListCollectionIds: [], namespaces: [Namespaces.ItemCollection.CloudEmojiPacks], aroundIndex: nil, count: 10000000) |> take(1), - combineLatest(keywords.map { context.engine.stickers.searchStickers(query: $0.emoticons.first!) }) + combineLatest(keywords.map { context.engine.stickers.searchStickers(query: $0.emoticons.first!) + |> map { items -> [FoundStickerItem] in + return items.items + } + }) ) |> map { view, stickers -> [EmojiPagerContentComponent.ItemGroup] in let hasPremium = true diff --git a/submodules/TelegramUI/Components/ChatEntityKeyboardInputNode/Sources/ChatEntityKeyboardInputNode.swift b/submodules/TelegramUI/Components/ChatEntityKeyboardInputNode/Sources/ChatEntityKeyboardInputNode.swift index 92ccb07f48..284007ea3c 100644 --- a/submodules/TelegramUI/Components/ChatEntityKeyboardInputNode/Sources/ChatEntityKeyboardInputNode.swift +++ b/submodules/TelegramUI/Components/ChatEntityKeyboardInputNode/Sources/ChatEntityKeyboardInputNode.swift @@ -1299,11 +1299,11 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode { strongSelf.stickerSearchResult.set(.single(nil)) case let .category(value): let resultSignal = strongSelf.context.engine.stickers.searchStickers(query: value, scope: [.installed, .remote]) - |> mapToSignal { files -> Signal<[EmojiPagerContentComponent.ItemGroup], NoError> in + |> mapToSignal { files -> Signal<(items: [EmojiPagerContentComponent.ItemGroup], isFinalResult: Bool), NoError> in var items: [EmojiPagerContentComponent.Item] = [] var existingIds = Set() - for item in files { + for item in files.items { let itemFile = item.file if existingIds.contains(itemFile.fileId) { continue @@ -1320,7 +1320,7 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode { items.append(item) } - return .single([EmojiPagerContentComponent.ItemGroup( + return .single(([EmojiPagerContentComponent.ItemGroup( supergroupId: "search", groupId: "search", title: nil, @@ -1334,7 +1334,7 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode { displayPremiumBadges: false, headerItem: nil, items: items - )]) + )], files.isFinalResult)) } strongSelf.stickerSearchDisposable.set((resultSignal @@ -1342,7 +1342,13 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode { guard let strongSelf = self else { return } - strongSelf.stickerSearchResult.set(.single((result, AnyHashable(value)))) + guard let group = result.items.first else { + return + } + if group.items.isEmpty && !result.isFinalResult { + return + } + strongSelf.stickerSearchResult.set(.single((result.items, AnyHashable(value)))) })) } }, diff --git a/submodules/TelegramUI/Components/ChatEntityKeyboardInputNode/Sources/StickerPaneSearchContentNode.swift b/submodules/TelegramUI/Components/ChatEntityKeyboardInputNode/Sources/StickerPaneSearchContentNode.swift index 78aa4ab462..3deadacafe 100644 --- a/submodules/TelegramUI/Components/ChatEntityKeyboardInputNode/Sources/StickerPaneSearchContentNode.swift +++ b/submodules/TelegramUI/Components/ChatEntityKeyboardInputNode/Sources/StickerPaneSearchContentNode.swift @@ -339,7 +339,7 @@ final class StickerPaneSearchContentNode: ASDisplayNode, PaneSearchContentNode { let query = text.trimmingCharacters(in: .whitespacesAndNewlines) if query.isSingleEmoji { signals = .single([context.engine.stickers.searchStickers(query: text.basicEmoji.0) - |> map { (nil, $0) }]) + |> map { (nil, $0.items) }]) } else if query.count > 1, let languageCode = languageCode, !languageCode.isEmpty && languageCode != "emoji" { var signal = context.engine.stickers.searchEmojiKeywords(inputLanguageCode: languageCode, query: query.lowercased(), completeMatch: query.count < 3) if !languageCode.lowercased().hasPrefix("en") { @@ -362,7 +362,7 @@ final class StickerPaneSearchContentNode: ASDisplayNode, PaneSearchContentNode { for emoji in emoticons { signals.append(context.engine.stickers.searchStickers(query: emoji.basicEmoji.0) // |> take(1) - |> map { (emoji, $0) }) + |> map { (emoji, $0.items) }) } return signals } diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift index bce7df4cd2..8d719df9ef 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift @@ -5005,6 +5005,14 @@ public final class EmojiPagerContentComponent: Component { scrollView.bounds = presentation.bounds scrollView.layer.removeAllAnimations() } + + if self.isSearchActivated, let visibleSearchHeader = self.visibleSearchHeader, visibleSearchHeader.currentPresetSearchTerm == nil { + scrollView.isScrollEnabled = false + DispatchQueue.main.async { + scrollView.isScrollEnabled = true + } + self.visibleSearchHeader?.deactivate() + } } public func scrollViewDidScroll(_ scrollView: UIScrollView) { @@ -5015,10 +5023,6 @@ public final class EmojiPagerContentComponent: Component { self.updateVisibleItems(transition: .immediate, attemptSynchronousLoads: false, previousItemPositions: nil, updatedItemPositions: nil) self.updateScrollingOffset(isReset: false, transition: .immediate) - - if self.isSearchActivated, let visibleSearchHeader = self.visibleSearchHeader, visibleSearchHeader.currentPresetSearchTerm == nil { - self.visibleSearchHeader?.deactivate() - } } public func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer) { @@ -6363,7 +6367,7 @@ public final class EmojiPagerContentComponent: Component { } } } else { - /*if component.inputInteractionHolder.inputInteraction?.externalBackground == nil { + /*if useOpaqueTheme { if visibleSearchHeader.superview != self.scrollView { self.scrollView.addSubview(visibleSearchHeader) self.mirrorContentScrollView.addSubview(visibleSearchHeader.tintContainerView) @@ -6419,7 +6423,7 @@ public final class EmojiPagerContentComponent: Component { let searchHeaderFrame = CGRect(origin: CGPoint(x: itemLayout.searchInsets.left, y: itemLayout.searchInsets.top), size: CGSize(width: itemLayout.width - itemLayout.searchInsets.left - itemLayout.searchInsets.right, height: itemLayout.searchHeight)) visibleSearchHeader.update(context: component.context, theme: keyboardChildEnvironment.theme, strings: keyboardChildEnvironment.strings, text: displaySearchWithPlaceholder, useOpaqueTheme: useOpaqueTheme, isActive: self.isSearchActivated, size: searchHeaderFrame.size, canFocus: !component.searchIsPlaceholderOnly, searchCategories: component.searchCategories, transition: transition) - transition.attachAnimation(view: visibleSearchHeader, completion: { [weak self] completed in + /*transition.attachAnimation(view: visibleSearchHeader, id: "search_transition", completion: { [weak self] completed in guard let strongSelf = self, completed, let visibleSearchHeader = strongSelf.visibleSearchHeader else { return } @@ -6428,8 +6432,41 @@ public final class EmojiPagerContentComponent: Component { strongSelf.scrollView.addSubview(visibleSearchHeader) strongSelf.mirrorContentScrollView.addSubview(visibleSearchHeader.tintContainerView) } - }) - transition.setFrame(view: visibleSearchHeader, frame: searchHeaderFrame) + })*/ + if visibleSearchHeader.frame != searchHeaderFrame { + transition.setFrame(view: visibleSearchHeader, frame: searchHeaderFrame, completion: { [weak self] completed in + if !useOpaqueTheme { + guard let strongSelf = self, completed, let visibleSearchHeader = strongSelf.visibleSearchHeader else { + return + } + + if !strongSelf.isSearchActivated && visibleSearchHeader.superview != strongSelf.scrollView { + strongSelf.scrollView.addSubview(visibleSearchHeader) + strongSelf.mirrorContentScrollView.addSubview(visibleSearchHeader.tintContainerView) + } + } + }) + // Temporary workaround for status selection; use a separate search container (see GIF) + if useOpaqueTheme { + if case let .curve(duration, _) = transition.animation, duration != 0.0 { + DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + duration, execute: { [weak self] in + guard let strongSelf = self, let visibleSearchHeader = strongSelf.visibleSearchHeader else { + return + } + + if !strongSelf.isSearchActivated && visibleSearchHeader.superview != strongSelf.scrollView { + strongSelf.scrollView.addSubview(visibleSearchHeader) + strongSelf.mirrorContentScrollView.addSubview(visibleSearchHeader.tintContainerView) + } + }) + } else { + if !self.isSearchActivated && visibleSearchHeader.superview != self.scrollView { + self.scrollView.addSubview(visibleSearchHeader) + self.mirrorContentScrollView.addSubview(visibleSearchHeader.tintContainerView) + } + } + } + } } else { if let visibleSearchHeader = self.visibleSearchHeader { self.visibleSearchHeader = nil diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiSearchSearchBarComponent.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiSearchSearchBarComponent.swift index a950fef04d..a9602eb0ff 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiSearchSearchBarComponent.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiSearchSearchBarComponent.swift @@ -288,6 +288,7 @@ final class EmojiSearchSearchBarComponent: Component { component.searchTermUpdated(group.identifiers.joined(separator: "")) } else { component.searchTermUpdated(nil) + self.scrollView.setContentOffset(CGPoint(), animated: true) } break @@ -301,6 +302,7 @@ final class EmojiSearchSearchBarComponent: Component { if self.selectedItem != nil { self.selectedItem = nil self.state?.updated(transition: .immediate) + self.scrollView.setContentOffset(CGPoint(), animated: true) if dispatchEvent { self.component?.searchTermUpdated(nil) } diff --git a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/DataUsageScreen.swift b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/DataUsageScreen.swift index 29b04bff7c..0bfaf88083 100644 --- a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/DataUsageScreen.swift +++ b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/DataUsageScreen.swift @@ -447,10 +447,10 @@ final class DataUsageScreenComponent: Component { headerOffset = min(headerOffset, minOffset) - let animatedTransition = Transition(animation: .curve(duration: 0.18, curve: .easeInOut)) + let animatedTransition = Transition(animation: .curve(duration: 0.2, curve: .easeInOut)) let navigationBackgroundAlpha: CGFloat = abs(headerOffset - minOffset) < 4.0 ? 1.0 : 0.0 - let navigationButtonAlpha: CGFloat = abs(headerOffset - minOffset) < 62.0 ? 0.0 : 1.0 + let navigationButtonAlpha: CGFloat = scrollBounds.minY >= navigationMetrics.navigationHeight ? 0.0 : 1.0 animatedTransition.setAlpha(view: self.navigationBackgroundView, alpha: navigationBackgroundAlpha) animatedTransition.setAlpha(layer: self.navigationSeparatorLayerContainer, alpha: navigationBackgroundAlpha) @@ -468,17 +468,19 @@ final class DataUsageScreenComponent: Component { transition.setBounds(view: self.headerOffsetContainer, bounds: CGRect(origin: CGPoint(x: 0.0, y: headerOffset), size: self.headerOffsetContainer.bounds.size)) if let controller = self.controller?(), let backButtonNode = controller.navigationBar?.backButtonNode { - if backButtonNode.isHidden { - backButtonNode.alpha = 0.0 - backButtonNode.isHidden = false - } - animatedTransition.setAlpha(layer: backButtonNode.layer, alpha: navigationButtonAlpha, completion: { [weak backButtonNode] completed in - if let backButtonNode, completed { - if navigationButtonAlpha.isZero { - backButtonNode.isHidden = true - } + if backButtonNode.alpha != navigationButtonAlpha { + if backButtonNode.isHidden { + backButtonNode.alpha = 0.0 + backButtonNode.isHidden = false } - }) + animatedTransition.setAlpha(layer: backButtonNode.layer, alpha: navigationButtonAlpha, completion: { [weak backButtonNode] completed in + if let backButtonNode, completed { + if navigationButtonAlpha.isZero { + backButtonNode.isHidden = true + } + } + }) + } } } } diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index adf90daa50..663922c2e5 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -18157,17 +18157,6 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G var itemList: [String] = [] - var flags: TelegramChatBannedRightsFlags = [] - if let channel = peer as? TelegramChannel { - if let bannedRights = channel.bannedRights { - flags = bannedRights.flags - } - } else if let group = peer as? TelegramGroup { - if let bannedRights = group.defaultBannedRights { - flags = bannedRights.flags - } - } - let order: [TelegramChatBannedRightsFlags] = [ .banSendText, .banSendPhotos, @@ -18180,32 +18169,40 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G ] for right in order { - if !flags.contains(right) { - var title: String? - switch right { - case .banSendText: - title = "text messages" - case .banSendPhotos: - title = "photos" - case .banSendVideos: - title = "videos" - case .banSendVoice: - title = "voice messages" - case .banSendInstantVideos: - title = "video messages" - case .banSendFiles: - title = "files" - case .banSendMusic: - title = "music" - case .banSendStickers: - title = "Stickers & GIFs" - default: - break + if let channel = peer as? TelegramChannel { + if channel.hasBannedPermission(right) != nil { + continue } - if let title { - itemList.append(title) + } else if let group = peer as? TelegramGroup { + if group.hasBannedPermission(right) { + continue } } + + var title: String? + switch right { + case .banSendText: + title = "text messages" + case .banSendPhotos: + title = "photos" + case .banSendVideos: + title = "videos" + case .banSendVoice: + title = "voice messages" + case .banSendInstantVideos: + title = "video messages" + case .banSendFiles: + title = "files" + case .banSendMusic: + title = "music" + case .banSendStickers: + title = "Stickers & GIFs" + default: + break + } + if let title { + itemList.append(title) + } } if itemList.isEmpty { diff --git a/submodules/TelegramUI/Sources/ChatInterfaceStateContextQueries.swift b/submodules/TelegramUI/Sources/ChatInterfaceStateContextQueries.swift index 5b82b8325e..519400ce3f 100644 --- a/submodules/TelegramUI/Sources/ChatInterfaceStateContextQueries.swift +++ b/submodules/TelegramUI/Sources/ChatInterfaceStateContextQueries.swift @@ -128,6 +128,9 @@ private func updatedContextQueryResultStateForQuery(context: AccountContext, pee scope = [.installed] } return context.engine.stickers.searchStickers(query: query.basicEmoji.0, scope: scope) + |> map { items -> [FoundStickerItem] in + return items.items + } |> castError(ChatContextQueryError.self) } |> map { stickers -> (ChatPresentationInputQueryResult?) -> ChatPresentationInputQueryResult? in diff --git a/submodules/TelegramUI/Sources/ChatInterfaceStateInputPanels.swift b/submodules/TelegramUI/Sources/ChatInterfaceStateInputPanels.swift index 30a7776995..3902434dfb 100644 --- a/submodules/TelegramUI/Sources/ChatInterfaceStateInputPanels.swift +++ b/submodules/TelegramUI/Sources/ChatInterfaceStateInputPanels.swift @@ -196,15 +196,15 @@ func inputPanelForChatPresentationIntefaceState(_ chatPresentationInterfaceState } } - if isMember && channel.hasBannedPermission(.banSendText) != nil && !channel.flags.contains(.isGigagroup) { - /*if let currentPanel = (currentPanel as? ChatRestrictedInputPanelNode) ?? (currentSecondaryPanel as? ChatRestrictedInputPanelNode) { + if isMember && !channel.hasPermission(.sendSomething) && !channel.flags.contains(.isGigagroup) { + if let currentPanel = (currentPanel as? ChatRestrictedInputPanelNode) ?? (currentSecondaryPanel as? ChatRestrictedInputPanelNode) { return (currentPanel, nil) } else { let panel = ChatRestrictedInputPanelNode() panel.context = context panel.interfaceInteraction = interfaceInteraction return (panel, nil) - }*/ + } } switch channel.info { @@ -280,15 +280,15 @@ func inputPanelForChatPresentationIntefaceState(_ chatPresentationInterfaceState break } - if group.hasBannedPermission(.banSendText) { - /*if let currentPanel = (currentPanel as? ChatRestrictedInputPanelNode) ?? (currentSecondaryPanel as? ChatRestrictedInputPanelNode) { + if !group.hasPermission(.sendSomething) { + if let currentPanel = (currentPanel as? ChatRestrictedInputPanelNode) ?? (currentSecondaryPanel as? ChatRestrictedInputPanelNode) { return (currentPanel, nil) } else { let panel = ChatRestrictedInputPanelNode() panel.context = context panel.interfaceInteraction = interfaceInteraction return (panel, nil) - }*/ + } } } diff --git a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift index 43f586c2d1..6139637e7c 100644 --- a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift @@ -2126,9 +2126,9 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { mediaInputDisabled = true } else if interfaceState.hasActiveGroupCall { mediaInputDisabled = true - } else if let channel = interfaceState.renderedPeer?.peer as? TelegramChannel, channel.hasBannedPermission(.banSendMedia) != nil { + } else if let channel = interfaceState.renderedPeer?.peer as? TelegramChannel, channel.hasBannedPermission(.banSendVoice) != nil, channel.hasBannedPermission(.banSendInstantVideos) != nil { mediaInputDisabled = true - } else if let group = interfaceState.renderedPeer?.peer as? TelegramGroup, group.hasBannedPermission(.banSendMedia) { + } else if let group = interfaceState.renderedPeer?.peer as? TelegramGroup, group.hasBannedPermission(.banSendVoice), group.hasBannedPermission(.banSendInstantVideos) { mediaInputDisabled = true } else { mediaInputDisabled = false diff --git a/submodules/UndoUI/Sources/UndoOverlayControllerNode.swift b/submodules/UndoUI/Sources/UndoOverlayControllerNode.swift index 0b00c2c95f..0a4c01fa7d 100644 --- a/submodules/UndoUI/Sources/UndoOverlayControllerNode.swift +++ b/submodules/UndoUI/Sources/UndoOverlayControllerNode.swift @@ -191,7 +191,7 @@ final class UndoOverlayControllerNode: ViewControllerTracingNode { return ("URL", contents) }), textAlignment: .natural) self.textNode.attributedText = attributedText - self.textNode.maximumNumberOfLines = 2 + self.textNode.maximumNumberOfLines = 10 displayUndo = false self.originalRemainingSeconds = Double(max(5, min(8, text.count / 14)))