From a6a9a2f7afbbcc4b6cf49c574e45571cf622f511 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Tue, 29 Sep 2020 01:33:08 +0400 Subject: [PATCH] Search filters fixes --- .../Sources/ChatListSearchContainerNode.swift | 14 ++++++++++++++ .../Sources/ChatListSearchListPaneNode.swift | 6 ++++-- submodules/GalleryData/Sources/GalleryData.swift | 2 +- .../NotificationExceptionControllerNode.swift | 2 +- .../TelegramUI/Sources/ChatHistoryListNode.swift | 4 ++-- 5 files changed, 22 insertions(+), 6 deletions(-) diff --git a/submodules/ChatListUI/Sources/ChatListSearchContainerNode.swift b/submodules/ChatListUI/Sources/ChatListSearchContainerNode.swift index 98ed922830..c558357c33 100644 --- a/submodules/ChatListUI/Sources/ChatListSearchContainerNode.swift +++ b/submodules/ChatListUI/Sources/ChatListSearchContainerNode.swift @@ -792,6 +792,13 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo if let strongSelf = self { // strongSelf.headerNode.navigationButtonContainer.performAction?(.selectionDone) let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: Array(messageIds), type: .forEveryone).start() + + strongSelf.updateState { state in + return state.withUpdatedSelectedMessageIds(nil) + } + if let (layout, navigationBarHeight) = strongSelf.validLayout { + strongSelf.containerLayoutUpdated(layout, navigationBarHeight: navigationBarHeight, transition: .animated(duration: 0.3, curve: .easeInOut)) + } } })) } @@ -809,6 +816,13 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo if let strongSelf = self { // strongSelf.headerNode.navigationButtonContainer.performAction?(.selectionDone) let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: Array(messageIds), type: .forLocalPeer).start() + + strongSelf.updateState { state in + return state.withUpdatedSelectedMessageIds(nil) + } + if let (layout, navigationBarHeight) = strongSelf.validLayout { + strongSelf.containerLayoutUpdated(layout, navigationBarHeight: navigationBarHeight, transition: .animated(duration: 0.3, curve: .easeInOut)) + } } })) } diff --git a/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift b/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift index 9c0c62870d..9611d3e41c 100644 --- a/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift +++ b/submodules/ChatListUI/Sources/ChatListSearchListPaneNode.swift @@ -657,6 +657,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode { private let searchStatePromise = ValuePromise() private let searchContextValue = Atomic(value: nil) var searchCurrentMessages: [Message]? + var currentEntries: [ChatListSearchEntry]? private var deletedMessagesDisposable: Disposable? @@ -1367,6 +1368,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode { }, searchQuery: strongSelf.searchQueryValue, searchOptions: strongSelf.searchOptionsValue, messageContextAction: { message, node, rect, gesture in interaction.messageContextAction(message, node, rect, gesture) }) + strongSelf.currentEntries = newEntries strongSelf.enqueueTransition(transition, firstTime: firstTime) var messages: [Message] = [] @@ -1966,7 +1968,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode { if !strongSelf.didSetReady && !strongSelf.recentListNode.isHidden { var ready: Signal? strongSelf.recentListNode.forEachItemNode { node in - if let node = node as? ChatListSearchRecentPeersNode { + if let node = node as? ChatListRecentPeersListItemNode { ready = node.isReady } } @@ -2058,7 +2060,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode { strongSelf.emptyResultsTextNode.isHidden = !emptyResults strongSelf.emptyResultsAnimationNode.visibility = emptyResults - let displayPlaceholder = transition.isLoading && (strongSelf.key != .chats || strongSelf.searchOptionsValue?.peer != nil || strongSelf.searchOptionsValue?.date != nil) + let displayPlaceholder = transition.isLoading && (strongSelf.key != .chats || (strongSelf.currentEntries?.isEmpty ?? true)) ContainedViewLayoutTransition.animated(duration: 0.2, curve: .easeInOut).updateAlpha(node: strongSelf.shimmerNode, alpha: displayPlaceholder ? 1.0 : 0.0) strongSelf.recentListNode.isHidden = displayingResults || strongSelf.peersFilter.contains(.excludeRecent) diff --git a/submodules/GalleryData/Sources/GalleryData.swift b/submodules/GalleryData/Sources/GalleryData.swift index a04e70fa18..b3482de298 100644 --- a/submodules/GalleryData/Sources/GalleryData.swift +++ b/submodules/GalleryData/Sources/GalleryData.swift @@ -116,7 +116,7 @@ public func chatMessageGalleryControllerData(context: AccountContext, chatLocati if let file = content.file { galleryMedia = file } else if let image = content.image { - if case .link = mode { + if case .link = mode, !["video"].contains(content.type) { } else if ["photo", "document", "video", "gif", "telegram_album"].contains(content.type) { galleryMedia = image } diff --git a/submodules/SettingsUI/Sources/Notifications/Exceptions/NotificationExceptionControllerNode.swift b/submodules/SettingsUI/Sources/Notifications/Exceptions/NotificationExceptionControllerNode.swift index 10bdec9795..0de1e56528 100644 --- a/submodules/SettingsUI/Sources/Notifications/Exceptions/NotificationExceptionControllerNode.swift +++ b/submodules/SettingsUI/Sources/Notifications/Exceptions/NotificationExceptionControllerNode.swift @@ -1334,7 +1334,7 @@ private final class NotificationExceptionsSearchContainerNode: SearchDisplayCont let (duration, curve) = listViewAnimationDurationAndCurve(transition: transition) self.listNode.frame = CGRect(origin: CGPoint(), size: layout.size) - self.listNode.transaction(deleteIndices: [], insertIndicesAndItems: [], updateIndicesAndItems: [], options: [.Synchronous], scrollToItem: nil, updateSizeAndInsets: ListViewUpdateSizeAndInsets(size: layout.size, insets: UIEdgeInsets(top: navigationBarHeight, left: 0.0, bottom: layout.insets(options: [.input]).bottom, right: 0.0), duration: duration, curve: curve), stationaryItemRange: nil, updateOpaqueState: nil, completion: { _ in }) + self.listNode.transaction(deleteIndices: [], insertIndicesAndItems: [], updateIndicesAndItems: [], options: [.Synchronous], scrollToItem: nil, updateSizeAndInsets: ListViewUpdateSizeAndInsets(size: layout.size, insets: UIEdgeInsets(top: navigationBarHeight, left: layout.safeInsets.left, bottom: layout.insets(options: [.input]).bottom, right: layout.safeInsets.right), duration: duration, curve: curve), stationaryItemRange: nil, updateOpaqueState: nil, completion: { _ in }) if !self.hasValidLayout { self.hasValidLayout = true diff --git a/submodules/TelegramUI/Sources/ChatHistoryListNode.swift b/submodules/TelegramUI/Sources/ChatHistoryListNode.swift index 022c8ef381..1983c669e0 100644 --- a/submodules/TelegramUI/Sources/ChatHistoryListNode.swift +++ b/submodules/TelegramUI/Sources/ChatHistoryListNode.swift @@ -268,7 +268,7 @@ private func mappedInsertEntries(context: AccountContext, chatLocation: ChatLoca switch mode { case .bubbles: item = ChatMessageItem(presentationData: presentationData, context: context, chatLocation: chatLocation, associatedData: associatedData, controllerInteraction: controllerInteraction, content: .group(messages: messages)) - case let .list(_, _, _, _, _): + case .list: assertionFailure() item = ListMessageItem(presentationData: presentationData, context: context, chatLocation: chatLocation, interaction: ListMessageItemInteraction(controllerInteraction: controllerInteraction), message: messages[0].0, selection: .none, displayHeader: false) } @@ -313,7 +313,7 @@ private func mappedUpdateEntries(context: AccountContext, chatLocation: ChatLoca switch mode { case .bubbles: item = ChatMessageItem(presentationData: presentationData, context: context, chatLocation: chatLocation, associatedData: associatedData, controllerInteraction: controllerInteraction, content: .group(messages: messages)) - case let .list(_, _, _, _, _): + case .list: assertionFailure() item = ListMessageItem(presentationData: presentationData, context: context, chatLocation: chatLocation, interaction: ListMessageItemInteraction(controllerInteraction: controllerInteraction), message: messages[0].0, selection: .none, displayHeader: false) }