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
880bbe0c5e
commit
78c90bceaf
@ -1606,6 +1606,8 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
|
||||
super.didLoad()
|
||||
|
||||
self.emptyResultsAnimationNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.animationTapGesture(_:))))
|
||||
|
||||
self.updateSelectedMessages(animated: false)
|
||||
}
|
||||
|
||||
private func updateState(_ f: (ChatListSearchListPaneNodeState) -> ChatListSearchListPaneNodeState) {
|
||||
|
@ -71,9 +71,6 @@ func suggestDates(for string: String, strings: PresentationStrings, dateTimeForm
|
||||
}
|
||||
|
||||
func getLowerMonthDate(month: Int, year: Int) -> Date {
|
||||
let monthComponents = DateComponents(year: year, month: month)
|
||||
let date = calendar.date(from: monthComponents)!
|
||||
let range = calendar.range(of: .day, in: .month, for: date)!
|
||||
let upperComponents = DateComponents(year: year, month: month, day: 1, hour: 0, minute: 0, second: 0)
|
||||
return calendar.date(from: upperComponents)!
|
||||
}
|
||||
@ -108,7 +105,7 @@ func suggestDates(for string: String, strings: PresentationStrings, dateTimeForm
|
||||
let stringComponents = string.components(separatedBy: dateSeparator)
|
||||
if stringComponents.count < 3 {
|
||||
for i in 0..<5 {
|
||||
if let date = calendar.date(byAdding: .year, value: -i, to: resultDate) {
|
||||
if let date = calendar.date(byAdding: .year, value: -i, to: resultDate), date < now {
|
||||
result.append((nil, date, nil))
|
||||
}
|
||||
}
|
||||
|
@ -1124,9 +1124,10 @@ public class GalleryController: ViewController, StandalonePresentableController
|
||||
|
||||
strongSelf.galleryNode.pager.replaceItems(items, centralItemIndex: centralItemIndex)
|
||||
}
|
||||
}
|
||||
|
||||
strongSelf.updateVisibleDisposable.set(nil)
|
||||
strongSelf.loadingMore = false
|
||||
}
|
||||
}))
|
||||
}
|
||||
default:
|
||||
|
@ -230,7 +230,7 @@ private final class LocalizationListSearchContainerNode: SearchDisplayController
|
||||
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
|
||||
|
@ -318,6 +318,7 @@ final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
||||
var currentItemDisappeared: (() -> Void)?
|
||||
|
||||
private let navigationDisposable = MetaDisposable()
|
||||
private let loadMoreDisposable = MetaDisposable()
|
||||
|
||||
private var playbackStack = PlaybackStack()
|
||||
|
||||
@ -325,6 +326,7 @@ final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
||||
private var currentlyObservedMessageId: MessageId?
|
||||
private let currentlyObservedMessageDisposable = MetaDisposable()
|
||||
private var loadingItem: Bool = false
|
||||
private var loadingMore: Bool = false
|
||||
private var playedToEnd: Bool = false
|
||||
private var order: MusicPlaybackSettingsOrder = .regular
|
||||
private(set) var looping: MusicPlaybackSettingsLooping = .none
|
||||
@ -357,6 +359,7 @@ final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
||||
|
||||
deinit {
|
||||
self.navigationDisposable.dispose()
|
||||
self.loadMoreDisposable.dispose()
|
||||
self.currentlyObservedMessageDisposable.dispose()
|
||||
}
|
||||
|
||||
@ -700,10 +703,10 @@ final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
||||
}
|
||||
}
|
||||
let historySignal = inputIndex
|
||||
|> mapToSignal { inputIndex -> Signal<(Message, [Message])?, NoError> in
|
||||
|> mapToSignal { inputIndex -> Signal<((Message, [Message])?, Int, Bool), NoError> in
|
||||
return messages
|
||||
|> take(1)
|
||||
|> mapToSignal { messages, _, loadMore -> Signal<(Message, [Message])?, NoError> in
|
||||
|> mapToSignal { messages, _, hasMore -> Signal<((Message, [Message])?, Int, Bool), NoError> in
|
||||
let position: NavigatedMessageFromViewPosition
|
||||
switch navigation {
|
||||
case .later:
|
||||
@ -717,10 +720,10 @@ final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
||||
if let (message, aroundMessages, exact) = navigatedMessageFromMessages(messages, anchorIndex: inputIndex, position: position) {
|
||||
switch navigation {
|
||||
case .random:
|
||||
return .single((message, []))
|
||||
return .single(((message, []), messages.count, false))
|
||||
default:
|
||||
if exact {
|
||||
return .single((message, aroundMessages))
|
||||
return .single(((message, aroundMessages), messages.count, false))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -732,7 +735,7 @@ final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
||||
} else {
|
||||
viewIndex = .lowerBound
|
||||
}
|
||||
return .single(nil)
|
||||
return .single((nil, messages.count, false))
|
||||
// return self.postbox.aroundMessageHistoryViewForLocation(.peer(peerId), anchor: viewIndex, count: 10, fixedCombinedReadStates: nil, topTaggedMessageIdNamespaces: [], tagMask: tagMask, namespaces: namespaces, orderStatistics: [])
|
||||
// |> mapToSignal { view -> Signal<(Message, [Message])?, NoError> in
|
||||
// let position: NavigatedMessageFromViewPosition
|
||||
@ -749,18 +752,41 @@ final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
||||
// }
|
||||
// }
|
||||
} else {
|
||||
return .single(nil)
|
||||
if hasMore {
|
||||
return .single((nil, messages.count, true))
|
||||
} else {
|
||||
return .single((nil, messages.count, false))
|
||||
}
|
||||
}
|
||||
|
||||
return .complete()
|
||||
}
|
||||
}
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue
|
||||
self.navigationDisposable.set(historySignal.start(next: { [weak self] messageAndAroundMessages in
|
||||
self.navigationDisposable.set(historySignal.start(next: { [weak self] messageAndAroundMessages, previousMessagesCount, shouldLoadMore in
|
||||
if let strongSelf = self {
|
||||
assert(strongSelf.loadingItem)
|
||||
|
||||
if shouldLoadMore {
|
||||
if strongSelf.loadingMore {
|
||||
return
|
||||
}
|
||||
strongSelf.loadingMore = true
|
||||
loadMore?()
|
||||
|
||||
strongSelf.loadMoreDisposable.set((messages
|
||||
|> deliverOnMainQueue).start(next: { messages, totalCount, hasMore in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
|
||||
if messages.count > previousMessagesCount {
|
||||
strongSelf.loadItem(anchor: anchor, navigation: navigation)
|
||||
|
||||
strongSelf.loadMoreDisposable.set(nil)
|
||||
strongSelf.loadingMore = false
|
||||
}
|
||||
}))
|
||||
} else {
|
||||
strongSelf.loadingItem = false
|
||||
if let (message, aroundMessages) = messageAndAroundMessages {
|
||||
if case let .random(previous) = navigation, previous {
|
||||
@ -775,6 +801,7 @@ final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
||||
}
|
||||
strongSelf.updateState()
|
||||
}
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user