mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Search filters fixes
This commit is contained in:
parent
f836ba1f09
commit
130cd724a3
@ -98,7 +98,6 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
|
|||||||
private let searchQuery = Promise<String?>(nil)
|
private let searchQuery = Promise<String?>(nil)
|
||||||
private var searchOptionsValue: ChatListSearchOptions?
|
private var searchOptionsValue: ChatListSearchOptions?
|
||||||
private let searchOptions = Promise<ChatListSearchOptions?>(nil)
|
private let searchOptions = Promise<ChatListSearchOptions?>(nil)
|
||||||
private let searchDisposable = MetaDisposable()
|
|
||||||
|
|
||||||
private var presentationData: PresentationData
|
private var presentationData: PresentationData
|
||||||
private var presentationDataDisposable: Disposable?
|
private var presentationDataDisposable: Disposable?
|
||||||
@ -155,7 +154,7 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
|
|||||||
if peer.id.namespace != Namespaces.Peer.SecretChat {
|
if peer.id.namespace != Namespaces.Peer.SecretChat {
|
||||||
addAppLogEvent(postbox: context.account.postbox, type: "search_global_open_message", peerId: peer.id, data: .dictionary(["msg_id": .number(Double(messageId.id))]))
|
addAppLogEvent(postbox: context.account.postbox, type: "search_global_open_message", peerId: peer.id, data: .dictionary(["msg_id": .number(Double(messageId.id))]))
|
||||||
}
|
}
|
||||||
}, openUrl: { url in
|
}, openUrl: { [weak self] url in
|
||||||
openUserGeneratedUrl(context: context, url: url, concealed: false, present: { c in
|
openUserGeneratedUrl(context: context, url: url, concealed: false, present: { c in
|
||||||
present(c, nil)
|
present(c, nil)
|
||||||
}, openResolved: { [weak self] resolved in
|
}, openResolved: { [weak self] resolved in
|
||||||
@ -329,7 +328,8 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
|
|||||||
} else {
|
} else {
|
||||||
isGroup = false
|
isGroup = false
|
||||||
}
|
}
|
||||||
suggestedFilters.append(.peer(peer.id, isGroup, peer.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder), peer.compactDisplayTitle))
|
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||||
|
suggestedFilters.append(.peer(peer.id, isGroup, peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), peer.compactDisplayTitle))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return suggestedFilters
|
return suggestedFilters
|
||||||
@ -375,7 +375,6 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
|
|||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
self.activeActionDisposable.dispose()
|
self.activeActionDisposable.dispose()
|
||||||
self.searchDisposable.dispose()
|
|
||||||
self.presentationDataDisposable?.dispose()
|
self.presentationDataDisposable?.dispose()
|
||||||
self.suggestedFiltersDisposable.dispose()
|
self.suggestedFiltersDisposable.dispose()
|
||||||
}
|
}
|
||||||
@ -545,7 +544,18 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
|
|||||||
|
|
||||||
transition.updateFrame(node: self.paneContainerNode, frame: CGRect(x: 0.0, y: topInset, width: layout.size.width, height: layout.size.height - topInset))
|
transition.updateFrame(node: self.paneContainerNode, frame: CGRect(x: 0.0, y: topInset, width: layout.size.width, height: layout.size.height - topInset))
|
||||||
|
|
||||||
self.paneContainerNode.update(size: CGSize(width: layout.size.width, height: layout.size.height - topInset), sideInset: layout.safeInsets.left, bottomInset: layout.inputHeight ?? 0.0, visibleHeight: layout.size.height - topInset, presentationData: self.presentationData, transition: transition)
|
var bottomInset = layout.intrinsicInsets.bottom
|
||||||
|
if let inputHeight = layout.inputHeight {
|
||||||
|
bottomInset = inputHeight
|
||||||
|
} else {
|
||||||
|
if !layout.safeInsets.left.isZero {
|
||||||
|
bottomInset -= 34.0
|
||||||
|
} else {
|
||||||
|
bottomInset -= 49.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
self.paneContainerNode.update(size: CGSize(width: layout.size.width, height: layout.size.height - topInset), sideInset: layout.safeInsets.left, bottomInset: bottomInset, visibleHeight: layout.size.height - topInset, presentationData: self.presentationData, transition: transition)
|
||||||
}
|
}
|
||||||
|
|
||||||
private var currentMessages: ([PeerId: Peer], [MessageId: Message]) {
|
private var currentMessages: ([PeerId: Peer], [MessageId: Message]) {
|
||||||
@ -713,7 +723,64 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
|
|||||||
}
|
}
|
||||||
|
|
||||||
func deleteMessages(messageIds: Set<MessageId>?) {
|
func deleteMessages(messageIds: Set<MessageId>?) {
|
||||||
let messageIds = messageIds ?? self.stateValue.selectedMessageIds
|
if let messageIds = messageIds ?? self.stateValue.selectedMessageIds, !messageIds.isEmpty {
|
||||||
|
self.activeActionDisposable.set((self.context.sharedContext.chatAvailableMessageActions(postbox: self.context.account.postbox, accountPeerId: self.context.account.peerId, messageIds: messageIds)
|
||||||
|
|> deliverOnMainQueue).start(next: { [weak self] actions in
|
||||||
|
if let strongSelf = self, !actions.options.isEmpty {
|
||||||
|
let actionSheet = ActionSheetController(presentationData: strongSelf.presentationData)
|
||||||
|
var items: [ActionSheetItem] = []
|
||||||
|
var personalPeerName: String?
|
||||||
|
var isChannel = false
|
||||||
|
// if let user = peer as? TelegramUser {
|
||||||
|
// personalPeerName = user.compactDisplayTitle
|
||||||
|
// } else if let channel = peer as? TelegramChannel, case .broadcast = channel.info {
|
||||||
|
// isChannel = true
|
||||||
|
// }
|
||||||
|
|
||||||
|
if actions.options.contains(.deleteGlobally) {
|
||||||
|
let globalTitle: String
|
||||||
|
if isChannel {
|
||||||
|
globalTitle = strongSelf.presentationData.strings.Conversation_DeleteMessagesForMe
|
||||||
|
} else if let personalPeerName = personalPeerName {
|
||||||
|
globalTitle = strongSelf.presentationData.strings.Conversation_DeleteMessagesFor(personalPeerName).0
|
||||||
|
} else {
|
||||||
|
globalTitle = strongSelf.presentationData.strings.Conversation_DeleteMessagesForEveryone
|
||||||
|
}
|
||||||
|
items.append(ActionSheetButtonItem(title: globalTitle, color: .destructive, action: { [weak actionSheet] in
|
||||||
|
actionSheet?.dismissAnimated()
|
||||||
|
if let strongSelf = self {
|
||||||
|
// strongSelf.headerNode.navigationButtonContainer.performAction?(.selectionDone)
|
||||||
|
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: Array(messageIds), type: .forEveryone).start()
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
if actions.options.contains(.deleteLocally) {
|
||||||
|
var localOptionText = strongSelf.presentationData.strings.Conversation_DeleteMessagesForMe
|
||||||
|
// if strongSelf.context.account.peerId == strongSelf.peerId {
|
||||||
|
// if messageIds.count == 1 {
|
||||||
|
// localOptionText = strongSelf.presentationData.strings.Conversation_Moderate_Delete
|
||||||
|
// } else {
|
||||||
|
// localOptionText = strongSelf.presentationData.strings.Conversation_DeleteManyMessages
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
items.append(ActionSheetButtonItem(title: localOptionText, color: .destructive, action: { [weak actionSheet] in
|
||||||
|
actionSheet?.dismissAnimated()
|
||||||
|
if let strongSelf = self {
|
||||||
|
// strongSelf.headerNode.navigationButtonContainer.performAction?(.selectionDone)
|
||||||
|
let _ = deleteMessagesInteractively(account: strongSelf.context.account, messageIds: Array(messageIds), type: .forLocalPeer).start()
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
actionSheet.setItemGroups([ActionSheetItemGroup(items: items), ActionSheetItemGroup(items: [
|
||||||
|
ActionSheetButtonItem(title: strongSelf.presentationData.strings.Common_Cancel, color: .accent, font: .bold, action: { [weak actionSheet] in
|
||||||
|
actionSheet?.dismissAnimated()
|
||||||
|
})
|
||||||
|
])])
|
||||||
|
strongSelf.view.endEditing(true)
|
||||||
|
strongSelf.present?(actionSheet, nil)
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func forwardMessages(messageIds: Set<MessageId>?) {
|
func forwardMessages(messageIds: Set<MessageId>?) {
|
||||||
|
@ -406,8 +406,7 @@ final class ChatListSearchFiltersContainerNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let selectedFrame = selectedFrame {
|
if let selectedFrame = selectedFrame {
|
||||||
let wasAdded = self.selectedLineNode.isHidden
|
let wasAdded = self.selectedLineNode.alpha < 1.0
|
||||||
self.selectedLineNode.isHidden = false
|
|
||||||
let lineFrame = CGRect(origin: CGPoint(x: selectedFrame.minX, y: size.height - 4.0), size: CGSize(width: selectedFrame.width, height: 4.0))
|
let lineFrame = CGRect(origin: CGPoint(x: selectedFrame.minX, y: size.height - 4.0), size: CGSize(width: selectedFrame.width, height: 4.0))
|
||||||
if wasAdded {
|
if wasAdded {
|
||||||
self.selectedLineNode.frame = lineFrame
|
self.selectedLineNode.frame = lineFrame
|
||||||
@ -441,7 +440,7 @@ final class ChatListSearchFiltersContainerNode: ASDisplayNode {
|
|||||||
self.previousSelectedAbsFrame = selectedFrame.offsetBy(dx: -self.scrollNode.bounds.minX, dy: 0.0)
|
self.previousSelectedAbsFrame = selectedFrame.offsetBy(dx: -self.scrollNode.bounds.minX, dy: 0.0)
|
||||||
self.previousSelectedFrame = selectedFrame
|
self.previousSelectedFrame = selectedFrame
|
||||||
} else {
|
} else {
|
||||||
self.selectedLineNode.isHidden = true
|
transition.updateAlpha(node: self.selectedLineNode, alpha: 0.0)
|
||||||
self.previousSelectedAbsFrame = nil
|
self.previousSelectedAbsFrame = nil
|
||||||
self.previousSelectedFrame = nil
|
self.previousSelectedFrame = nil
|
||||||
}
|
}
|
||||||
|
@ -875,19 +875,19 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
|
|||||||
let location: SearchMessagesLocation
|
let location: SearchMessagesLocation
|
||||||
if let options = options {
|
if let options = options {
|
||||||
if let (peerId, _, _) = options.peer {
|
if let (peerId, _, _) = options.peer {
|
||||||
location = .peer(peerId: peerId, fromId: nil, tags: self.tagMask, topMsgId: nil, minDate: options.minDate?.0, maxDate: options.maxDate?.0)
|
location = .peer(peerId: peerId, fromId: nil, tags: tagMask, topMsgId: nil, minDate: options.minDate?.0, maxDate: options.maxDate?.0)
|
||||||
} else {
|
} else {
|
||||||
if let groupId = groupId {
|
if let groupId = groupId {
|
||||||
location = .group(groupId: groupId, tags: self.tagMask, minDate: options.minDate?.0, maxDate: options.maxDate?.0)
|
location = .group(groupId: groupId, tags: tagMask, minDate: options.minDate?.0, maxDate: options.maxDate?.0)
|
||||||
} else {
|
} else {
|
||||||
location = .general(tags: self.tagMask, minDate: options.minDate?.0, maxDate: options.maxDate?.0)
|
location = .general(tags: tagMask, minDate: options.minDate?.0, maxDate: options.maxDate?.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if let groupId = groupId {
|
if let groupId = groupId {
|
||||||
location = .group(groupId: groupId, tags: self.tagMask, minDate: nil, maxDate: nil)
|
location = .group(groupId: groupId, tags: tagMask, minDate: nil, maxDate: nil)
|
||||||
} else {
|
} else {
|
||||||
location = .general(tags: self.tagMask, minDate: nil, maxDate: nil)
|
location = .general(tags: tagMask, minDate: nil, maxDate: nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1250,7 +1250,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return transitionNode
|
return transitionNode
|
||||||
}, addToTransitionSurface: { view in
|
}, addToTransitionSurface: { [weak self] view in
|
||||||
self?.addToTransitionSurface(view: view)
|
self?.addToTransitionSurface(view: view)
|
||||||
}, openUrl: { url in
|
}, openUrl: { url in
|
||||||
interaction.openUrl(url)
|
interaction.openUrl(url)
|
||||||
@ -1304,20 +1304,11 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
|
|||||||
strongSelf._isSearching.set(isSearching)
|
strongSelf._isSearching.set(isSearching)
|
||||||
|
|
||||||
if strongSelf.tagMask == .photoOrVideo {
|
if strongSelf.tagMask == .photoOrVideo {
|
||||||
var totalCount: Int32 = 0
|
|
||||||
if let entries = entriesAndFlags?.0 {
|
|
||||||
for entry in entries {
|
|
||||||
if case let .message(_, _, _, _, count, _, _) = entry {
|
|
||||||
totalCount = count
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var entries: [ChatListSearchEntry]? = entriesAndFlags?.0 ?? []
|
var entries: [ChatListSearchEntry]? = entriesAndFlags?.0 ?? []
|
||||||
if isSearching && (entries?.isEmpty ?? true) {
|
if isSearching && (entries?.isEmpty ?? true) {
|
||||||
entries = nil
|
entries = nil
|
||||||
}
|
}
|
||||||
strongSelf.mediaNode.updateHistory(entries: entries, totalCount: totalCount, updateType: .Initial)
|
strongSelf.mediaNode.updateHistory(entries: entries, totalCount: 0, updateType: .Initial)
|
||||||
}
|
}
|
||||||
|
|
||||||
var entriesAndFlags = entriesAndFlags
|
var entriesAndFlags = entriesAndFlags
|
||||||
@ -1328,6 +1319,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
|
|||||||
for entry in entries {
|
for entry in entries {
|
||||||
if case let .localPeer(peer, _, _, _, _, _, _, _, _) = entry {
|
if case let .localPeer(peer, _, _, _, _, _, _, _, _) = entry {
|
||||||
peers.append(peer)
|
peers.append(peer)
|
||||||
|
} else if case .globalPeer = entry {
|
||||||
} else {
|
} else {
|
||||||
filteredEntries.append(entry)
|
filteredEntries.append(entry)
|
||||||
}
|
}
|
||||||
@ -1345,7 +1337,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
|
|||||||
let firstTime = previousEntries == nil
|
let firstTime = previousEntries == nil
|
||||||
let transition = chatListSearchContainerPreparedTransition(from: previousEntries ?? [], to: newEntries, displayingResults: entriesAndFlags?.0 != nil, isEmpty: !isSearching && (entriesAndFlags?.0.isEmpty ?? false), isLoading: isSearching, animated: animated, context: context, presentationData: strongSelf.presentationData, enableHeaders: true, filter: peersFilter, tagMask: tagMask, interaction: chatListInteraction, listInteraction: listInteraction, peerContextAction: { message, node, rect, gesture in
|
let transition = chatListSearchContainerPreparedTransition(from: previousEntries ?? [], to: newEntries, displayingResults: entriesAndFlags?.0 != nil, isEmpty: !isSearching && (entriesAndFlags?.0.isEmpty ?? false), isLoading: isSearching, animated: animated, context: context, presentationData: strongSelf.presentationData, enableHeaders: true, filter: peersFilter, tagMask: tagMask, interaction: chatListInteraction, listInteraction: listInteraction, peerContextAction: { message, node, rect, gesture in
|
||||||
interaction.peerContextAction?(message, node, rect, gesture)
|
interaction.peerContextAction?(message, node, rect, gesture)
|
||||||
}, toggleExpandLocalResults: {
|
}, toggleExpandLocalResults: { [weak self] in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1354,7 +1346,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
|
|||||||
state.expandLocalSearch = !state.expandLocalSearch
|
state.expandLocalSearch = !state.expandLocalSearch
|
||||||
return state
|
return state
|
||||||
}
|
}
|
||||||
}, toggleExpandGlobalResults: {
|
}, toggleExpandGlobalResults: { [weak self] in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -1484,9 +1476,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
|
|||||||
}, clearRecentlySearchedPeers: {
|
}, clearRecentlySearchedPeers: {
|
||||||
interaction.clearRecentSearch()
|
interaction.clearRecentSearch()
|
||||||
}, deletePeer: { peerId in
|
}, deletePeer: { peerId in
|
||||||
if let strongSelf = self {
|
let _ = removeRecentlySearchedPeer(postbox: context.account.postbox, peerId: peerId).start()
|
||||||
let _ = removeRecentlySearchedPeer(postbox: strongSelf.context.account.postbox, peerId: peerId).start()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
strongSelf.enqueueRecentTransition(transition, firstTime: firstTime)
|
strongSelf.enqueueRecentTransition(transition, firstTime: firstTime)
|
||||||
}
|
}
|
||||||
|
@ -353,7 +353,7 @@ public final class ListMessageSnippetItemNode: ListMessageNode {
|
|||||||
|
|
||||||
let rawUrlString = urlString
|
let rawUrlString = urlString
|
||||||
var parsedUrl = URL(string: urlString)
|
var parsedUrl = URL(string: urlString)
|
||||||
if parsedUrl == nil || parsedUrl!.host == nil || parsedUrl!.host!.isEmpty {
|
if (parsedUrl == nil || parsedUrl!.host == nil || parsedUrl!.host!.isEmpty) && !urlString.contains("@") {
|
||||||
urlString = "http://" + urlString
|
urlString = "http://" + urlString
|
||||||
parsedUrl = URL(string: urlString)
|
parsedUrl = URL(string: urlString)
|
||||||
}
|
}
|
||||||
@ -400,7 +400,7 @@ public final class ListMessageSnippetItemNode: ListMessageNode {
|
|||||||
var (urlString, concealed) = parseUrl(url: url, wasConcealed: false)
|
var (urlString, concealed) = parseUrl(url: url, wasConcealed: false)
|
||||||
let rawUrlString = urlString
|
let rawUrlString = urlString
|
||||||
var parsedUrl = URL(string: urlString)
|
var parsedUrl = URL(string: urlString)
|
||||||
if parsedUrl == nil || parsedUrl!.host == nil || parsedUrl!.host!.isEmpty {
|
if (parsedUrl == nil || parsedUrl!.host == nil || parsedUrl!.host!.isEmpty) && !urlString.contains("@") {
|
||||||
urlString = "http://" + urlString
|
urlString = "http://" + urlString
|
||||||
parsedUrl = URL(string: urlString)
|
parsedUrl = URL(string: urlString)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user