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()
|
super.didLoad()
|
||||||
|
|
||||||
self.emptyResultsAnimationNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.animationTapGesture(_:))))
|
self.emptyResultsAnimationNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.animationTapGesture(_:))))
|
||||||
|
|
||||||
|
self.updateSelectedMessages(animated: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func updateState(_ f: (ChatListSearchListPaneNodeState) -> ChatListSearchListPaneNodeState) {
|
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 {
|
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)
|
let upperComponents = DateComponents(year: year, month: month, day: 1, hour: 0, minute: 0, second: 0)
|
||||||
return calendar.date(from: upperComponents)!
|
return calendar.date(from: upperComponents)!
|
||||||
}
|
}
|
||||||
@ -108,7 +105,7 @@ func suggestDates(for string: String, strings: PresentationStrings, dateTimeForm
|
|||||||
let stringComponents = string.components(separatedBy: dateSeparator)
|
let stringComponents = string.components(separatedBy: dateSeparator)
|
||||||
if stringComponents.count < 3 {
|
if stringComponents.count < 3 {
|
||||||
for i in 0..<5 {
|
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))
|
result.append((nil, date, nil))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1124,9 +1124,10 @@ public class GalleryController: ViewController, StandalonePresentableController
|
|||||||
|
|
||||||
strongSelf.galleryNode.pager.replaceItems(items, centralItemIndex: centralItemIndex)
|
strongSelf.galleryNode.pager.replaceItems(items, centralItemIndex: centralItemIndex)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
strongSelf.updateVisibleDisposable.set(nil)
|
||||||
|
strongSelf.loadingMore = false
|
||||||
}
|
}
|
||||||
|
|
||||||
strongSelf.loadingMore = false
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -230,7 +230,7 @@ private final class LocalizationListSearchContainerNode: SearchDisplayController
|
|||||||
let (duration, curve) = listViewAnimationDurationAndCurve(transition: transition)
|
let (duration, curve) = listViewAnimationDurationAndCurve(transition: transition)
|
||||||
|
|
||||||
self.listNode.frame = CGRect(origin: CGPoint(), size: layout.size)
|
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 {
|
if !self.hasValidLayout {
|
||||||
self.hasValidLayout = true
|
self.hasValidLayout = true
|
||||||
|
@ -318,6 +318,7 @@ final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
|||||||
var currentItemDisappeared: (() -> Void)?
|
var currentItemDisappeared: (() -> Void)?
|
||||||
|
|
||||||
private let navigationDisposable = MetaDisposable()
|
private let navigationDisposable = MetaDisposable()
|
||||||
|
private let loadMoreDisposable = MetaDisposable()
|
||||||
|
|
||||||
private var playbackStack = PlaybackStack()
|
private var playbackStack = PlaybackStack()
|
||||||
|
|
||||||
@ -325,6 +326,7 @@ final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
|||||||
private var currentlyObservedMessageId: MessageId?
|
private var currentlyObservedMessageId: MessageId?
|
||||||
private let currentlyObservedMessageDisposable = MetaDisposable()
|
private let currentlyObservedMessageDisposable = MetaDisposable()
|
||||||
private var loadingItem: Bool = false
|
private var loadingItem: Bool = false
|
||||||
|
private var loadingMore: Bool = false
|
||||||
private var playedToEnd: Bool = false
|
private var playedToEnd: Bool = false
|
||||||
private var order: MusicPlaybackSettingsOrder = .regular
|
private var order: MusicPlaybackSettingsOrder = .regular
|
||||||
private(set) var looping: MusicPlaybackSettingsLooping = .none
|
private(set) var looping: MusicPlaybackSettingsLooping = .none
|
||||||
@ -357,6 +359,7 @@ final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
|||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
self.navigationDisposable.dispose()
|
self.navigationDisposable.dispose()
|
||||||
|
self.loadMoreDisposable.dispose()
|
||||||
self.currentlyObservedMessageDisposable.dispose()
|
self.currentlyObservedMessageDisposable.dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -700,10 +703,10 @@ final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let historySignal = inputIndex
|
let historySignal = inputIndex
|
||||||
|> mapToSignal { inputIndex -> Signal<(Message, [Message])?, NoError> in
|
|> mapToSignal { inputIndex -> Signal<((Message, [Message])?, Int, Bool), NoError> in
|
||||||
return messages
|
return messages
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|> mapToSignal { messages, _, loadMore -> Signal<(Message, [Message])?, NoError> in
|
|> mapToSignal { messages, _, hasMore -> Signal<((Message, [Message])?, Int, Bool), NoError> in
|
||||||
let position: NavigatedMessageFromViewPosition
|
let position: NavigatedMessageFromViewPosition
|
||||||
switch navigation {
|
switch navigation {
|
||||||
case .later:
|
case .later:
|
||||||
@ -717,10 +720,10 @@ final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
|||||||
if let (message, aroundMessages, exact) = navigatedMessageFromMessages(messages, anchorIndex: inputIndex, position: position) {
|
if let (message, aroundMessages, exact) = navigatedMessageFromMessages(messages, anchorIndex: inputIndex, position: position) {
|
||||||
switch navigation {
|
switch navigation {
|
||||||
case .random:
|
case .random:
|
||||||
return .single((message, []))
|
return .single(((message, []), messages.count, false))
|
||||||
default:
|
default:
|
||||||
if exact {
|
if exact {
|
||||||
return .single((message, aroundMessages))
|
return .single(((message, aroundMessages), messages.count, false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -732,7 +735,7 @@ final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
|||||||
} else {
|
} else {
|
||||||
viewIndex = .lowerBound
|
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: [])
|
// 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
|
// |> mapToSignal { view -> Signal<(Message, [Message])?, NoError> in
|
||||||
// let position: NavigatedMessageFromViewPosition
|
// let position: NavigatedMessageFromViewPosition
|
||||||
@ -749,31 +752,55 @@ final class PeerMessagesMediaPlaylist: SharedMediaPlaylist {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
} else {
|
} else {
|
||||||
return .single(nil)
|
if hasMore {
|
||||||
|
return .single((nil, messages.count, true))
|
||||||
|
} else {
|
||||||
|
return .single((nil, messages.count, false))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return .complete()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|> deliverOnMainQueue
|
|> 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 {
|
if let strongSelf = self {
|
||||||
assert(strongSelf.loadingItem)
|
assert(strongSelf.loadingItem)
|
||||||
|
|
||||||
strongSelf.loadingItem = false
|
if shouldLoadMore {
|
||||||
if let (message, aroundMessages) = messageAndAroundMessages {
|
if strongSelf.loadingMore {
|
||||||
if case let .random(previous) = navigation, previous {
|
return
|
||||||
strongSelf.playbackStack.resetToId(message.id)
|
|
||||||
} else {
|
|
||||||
strongSelf.playbackStack.push(message.id)
|
|
||||||
}
|
}
|
||||||
strongSelf.currentItem = (message, aroundMessages)
|
strongSelf.loadingMore = true
|
||||||
strongSelf.playedToEnd = false
|
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 {
|
} else {
|
||||||
strongSelf.playedToEnd = true
|
strongSelf.loadingItem = false
|
||||||
|
if let (message, aroundMessages) = messageAndAroundMessages {
|
||||||
|
if case let .random(previous) = navigation, previous {
|
||||||
|
strongSelf.playbackStack.resetToId(message.id)
|
||||||
|
} else {
|
||||||
|
strongSelf.playbackStack.push(message.id)
|
||||||
|
}
|
||||||
|
strongSelf.currentItem = (message, aroundMessages)
|
||||||
|
strongSelf.playedToEnd = false
|
||||||
|
} else {
|
||||||
|
strongSelf.playedToEnd = true
|
||||||
|
}
|
||||||
|
strongSelf.updateState()
|
||||||
}
|
}
|
||||||
strongSelf.updateState()
|
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user