Various fixes

This commit is contained in:
Ilya Laktyushin 2022-04-12 17:44:19 +04:00
parent 56d3f1237b
commit 33c627fb75
8 changed files with 144 additions and 45 deletions

View File

@ -923,6 +923,32 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
let searchStatePromise = self.searchStatePromise let searchStatePromise = self.searchStatePromise
let selectionPromise = self.selectedMessagesPromise let selectionPromise = self.selectedMessagesPromise
let previousRecentlySearchedPeerOrder = Atomic<[EnginePeer.Id]>(value: [])
let fixedRecentlySearchedPeers = context.engine.peers.recentlySearchedPeers()
|> map { peers -> [RecentlySearchedPeer] in
var result: [RecentlySearchedPeer] = []
let _ = previousRecentlySearchedPeerOrder.modify { current in
var updated: [EnginePeer.Id] = []
for id in current {
inner: for peer in peers {
if peer.peer.peerId == id {
updated.append(id)
result.append(peer)
break inner
}
}
}
for peer in peers.reversed() {
if !updated.contains(peer.peer.peerId) {
updated.insert(peer.peer.peerId, at: 0)
result.insert(peer, at: 0)
}
}
return updated
}
return result
}
let downloadItems: Signal<(inProgressItems: [DownloadItem], doneItems: [RenderedRecentDownloadItem]), NoError> let downloadItems: Signal<(inProgressItems: [DownloadItem], doneItems: [RenderedRecentDownloadItem]), NoError>
if key == .downloads { if key == .downloads {
var firstTime = true var firstTime = true
@ -1207,8 +1233,8 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
} }
}) })
return combineLatest(accountPeer, foundLocalPeers, foundRemotePeers, foundRemoteMessages, presentationDataPromise.get(), searchStatePromise.get(), selectionPromise.get(), resolvedMessage) return combineLatest(accountPeer, foundLocalPeers, foundRemotePeers, foundRemoteMessages, presentationDataPromise.get(), searchStatePromise.get(), selectionPromise.get(), resolvedMessage, fixedRecentlySearchedPeers)
|> map { accountPeer, foundLocalPeers, foundRemotePeers, foundRemoteMessages, presentationData, searchState, selectionState, resolvedMessage -> ([ChatListSearchEntry], Bool)? in |> map { accountPeer, foundLocalPeers, foundRemotePeers, foundRemoteMessages, presentationData, searchState, selectionState, resolvedMessage, recentPeers -> ([ChatListSearchEntry], Bool)? in
let isSearching = foundRemotePeers.2 || foundRemoteMessages.1 let isSearching = foundRemotePeers.2 || foundRemoteMessages.1
var entries: [ChatListSearchEntry] = [] var entries: [ChatListSearchEntry] = []
var index = 0 var index = 0
@ -1293,6 +1319,30 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
} }
} }
if lowercasedQuery.count > 1 {
for peer in recentPeers {
if let peer = peer.peer.chatMainPeer, !existingPeerIds.contains(peer.id) {
let peer = EnginePeer(peer)
var matches = false
if case let .user(user) = peer {
if let firstName = user.firstName, firstName.lowercased().hasPrefix(lowercasedQuery) {
matches = true
} else if let lastName = user.lastName, lastName.lowercased().hasPrefix(lowercasedQuery) {
matches = true
}
} else if peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder).lowercased().hasPrefix(lowercasedQuery) {
matches = true
}
if matches {
existingPeerIds.insert(peer.id)
entries.append(.localPeer(peer, nil, nil, index, presentationData.theme, presentationData.strings, presentationData.nameSortOrder, presentationData.nameDisplayOrder, localExpandType))
}
}
}
}
var numberOfLocalPeers = 0 var numberOfLocalPeers = 0
for renderedPeer in foundLocalPeers.peers { for renderedPeer in foundLocalPeers.peers {
if case .expand = localExpandType, numberOfLocalPeers >= 3 { if case .expand = localExpandType, numberOfLocalPeers >= 3 {
@ -1745,32 +1795,6 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
} }
|> distinctUntilChanged |> distinctUntilChanged
let previousRecentlySearchedPeerOrder = Atomic<[EnginePeer.Id]>(value: [])
let fixedRecentlySearchedPeers = context.engine.peers.recentlySearchedPeers()
|> map { peers -> [RecentlySearchedPeer] in
var result: [RecentlySearchedPeer] = []
let _ = previousRecentlySearchedPeerOrder.modify { current in
var updated: [EnginePeer.Id] = []
for id in current {
inner: for peer in peers {
if peer.peer.peerId == id {
updated.append(id)
result.append(peer)
break inner
}
}
}
for peer in peers.reversed() {
if !updated.contains(peer.peer.peerId) {
updated.insert(peer.peer.peerId, at: 0)
result.insert(peer, at: 0)
}
}
return updated
}
return result
}
var recentItems = combineLatest(hasRecentPeers, fixedRecentlySearchedPeers, presentationDataPromise.get()) var recentItems = combineLatest(hasRecentPeers, fixedRecentlySearchedPeers, presentationDataPromise.get())
|> mapToSignal { hasRecentPeers, peers, presentationData -> Signal<[ChatListRecentEntry], NoError> in |> mapToSignal { hasRecentPeers, peers, presentationData -> Signal<[ChatListRecentEntry], NoError> in
var entries: [ChatListRecentEntry] = [] var entries: [ChatListRecentEntry] = []

View File

@ -68,6 +68,7 @@ final class InstantPageControllerNode: ASDisplayNode, UIScrollViewDelegate {
var currentAccessibilityAreas: [AccessibilityAreaNode] = [] var currentAccessibilityAreas: [AccessibilityAreaNode] = []
private var previousContentOffset: CGPoint?
private var isDeceleratingBecauseOfDragging = false private var isDeceleratingBecauseOfDragging = false
private let hiddenMediaDisposable = MetaDisposable() private let hiddenMediaDisposable = MetaDisposable()
@ -392,6 +393,7 @@ final class InstantPageControllerNode: ASDisplayNode, UIScrollViewDelegate {
} }
self.scrollNode.view.contentOffset = contentOffset self.scrollNode.view.contentOffset = contentOffset
if didSetScrollOffset { if didSetScrollOffset {
self.previousContentOffset = contentOffset
self.updateNavigationBar() self.updateNavigationBar()
if self.currentLayout != nil { if self.currentLayout != nil {
self.setupScrollOffsetOnLayout = false self.setupScrollOffsetOnLayout = false
@ -707,6 +709,8 @@ final class InstantPageControllerNode: ASDisplayNode, UIScrollViewDelegate {
func scrollViewDidScroll(_ scrollView: UIScrollView) { func scrollViewDidScroll(_ scrollView: UIScrollView) {
self.updateVisibleItems(visibleBounds: self.scrollNode.view.bounds) self.updateVisibleItems(visibleBounds: self.scrollNode.view.bounds)
self.updateNavigationBar()
self.previousContentOffset = self.scrollNode.view.contentOffset
} }
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
@ -727,6 +731,7 @@ final class InstantPageControllerNode: ASDisplayNode, UIScrollViewDelegate {
} }
let bounds = self.scrollNode.view.bounds let bounds = self.scrollNode.view.bounds
let contentOffset = self.scrollNode.view.contentOffset
let maxBarHeight: CGFloat let maxBarHeight: CGFloat
let minBarHeight: CGFloat let minBarHeight: CGFloat
@ -742,14 +747,55 @@ final class InstantPageControllerNode: ASDisplayNode, UIScrollViewDelegate {
minBarHeight = 20.0 minBarHeight = 20.0
} }
let transition: ContainedViewLayoutTransition = .immediate var pageProgress: CGFloat = 0.0
if !self.scrollNode.view.contentSize.height.isZero {
let value = (contentOffset.y + self.scrollNode.view.contentInset.top) / (self.scrollNode.view.contentSize.height - bounds.size.height + self.scrollNode.view.contentInset.top)
pageProgress = max(0.0, min(1.0, value))
}
let delta: CGFloat
if self.setupScrollOffsetOnLayout {
delta = 0.0
} else if let previousContentOffset = self.previousContentOffset {
delta = contentOffset.y - previousContentOffset.y
} else {
delta = 0.0
}
self.previousContentOffset = contentOffset
var transition: ContainedViewLayoutTransition = .immediate
var navigationBarFrame = self.navigationBar.frame var navigationBarFrame = self.navigationBar.frame
navigationBarFrame.size.width = bounds.size.width navigationBarFrame.size.width = bounds.size.width
if navigationBarFrame.size.height.isZero { if navigationBarFrame.size.height.isZero {
navigationBarFrame.size.height = maxBarHeight navigationBarFrame.size.height = maxBarHeight
} }
if case .regular = containerLayout.metrics.widthClass {
navigationBarFrame.size.height = maxBarHeight navigationBarFrame.size.height = maxBarHeight
} else {
if forceState {
transition = .animated(duration: 0.3, curve: .spring)
let transitionFactor = (navigationBarFrame.size.height - minBarHeight) / (maxBarHeight - minBarHeight)
if contentOffset.y <= -self.scrollNode.view.contentInset.top || transitionFactor > 0.4 {
navigationBarFrame.size.height = maxBarHeight
} else {
navigationBarFrame.size.height = minBarHeight
}
} else {
if contentOffset.y <= -self.scrollNode.view.contentInset.top {
navigationBarFrame.size.height = maxBarHeight
} else {
navigationBarFrame.size.height -= delta
}
navigationBarFrame.size.height = max(minBarHeight, min(maxBarHeight, navigationBarFrame.size.height))
}
if self.setupScrollOffsetOnLayout {
navigationBarFrame.size.height = maxBarHeight
}
}
let transitionFactor = (navigationBarFrame.size.height - minBarHeight) / (maxBarHeight - minBarHeight) let transitionFactor = (navigationBarFrame.size.height - minBarHeight) / (maxBarHeight - minBarHeight)
@ -768,7 +814,7 @@ final class InstantPageControllerNode: ASDisplayNode, UIScrollViewDelegate {
} }
transition.updateFrame(node: self.navigationBar, frame: navigationBarFrame) transition.updateFrame(node: self.navigationBar, frame: navigationBarFrame)
self.navigationBar.updateLayout(size: navigationBarFrame.size, minHeight: minBarHeight, maxHeight: maxBarHeight, topInset: containerLayout.safeInsets.top, leftInset: containerLayout.safeInsets.left, rightInset: containerLayout.safeInsets.right, title: title, pageProgress: 0.0, transition: transition) self.navigationBar.updateLayout(size: navigationBarFrame.size, minHeight: minBarHeight, maxHeight: maxBarHeight, topInset: containerLayout.safeInsets.top, leftInset: containerLayout.safeInsets.left, rightInset: containerLayout.safeInsets.right, title: title, pageProgress: pageProgress, transition: transition)
transition.animateView { transition.animateView {
self.scrollNode.view.scrollIndicatorInsets = UIEdgeInsets(top: navigationBarFrame.size.height, left: 0.0, bottom: containerLayout.intrinsicInsets.bottom, right: 0.0) self.scrollNode.view.scrollIndicatorInsets = UIEdgeInsets(top: navigationBarFrame.size.height, left: 0.0, bottom: containerLayout.intrinsicInsets.bottom, right: 0.0)

View File

@ -169,7 +169,7 @@ final class InstantPageNavigationBar: ASDisplayNode {
func updateLayout(size: CGSize, minHeight: CGFloat, maxHeight: CGFloat, topInset: CGFloat, leftInset: CGFloat, rightInset: CGFloat, title: String?, pageProgress: CGFloat, transition: ContainedViewLayoutTransition) { func updateLayout(size: CGSize, minHeight: CGFloat, maxHeight: CGFloat, topInset: CGFloat, leftInset: CGFloat, rightInset: CGFloat, title: String?, pageProgress: CGFloat, transition: ContainedViewLayoutTransition) {
let progressHeight: CGFloat let progressHeight: CGFloat
if !topInset.isZero { if !topInset.isZero {
progressHeight = size.height - topInset + 11.0 progressHeight = size.height - topInset + 11.0 - UIScreenPixel
} else { } else {
progressHeight = size.height progressHeight = size.height
} }

View File

@ -808,6 +808,7 @@ public class ItemListAvatarAndNameInfoItemNode: ListViewItemNode, ItemListItemNo
if strongSelf.inputFirstField == nil { if strongSelf.inputFirstField == nil {
let inputFirstField = TextFieldNodeView() let inputFirstField = TextFieldNodeView()
inputFirstField.returnKeyType = .done
inputFirstField.delegate = self inputFirstField.delegate = self
inputFirstField.font = Font.regular(floor(item.presentationData.fontSize.itemListBaseFontSize * 19.0 / 17.0)) inputFirstField.font = Font.regular(floor(item.presentationData.fontSize.itemListBaseFontSize * 19.0 / 17.0))
inputFirstField.autocorrectionType = .no inputFirstField.autocorrectionType = .no

View File

@ -178,13 +178,13 @@ public func customizeDefaultDarkPresentationTheme(theme: PresentationTheme, edit
reactionInactiveBackground: UIColor(rgb: 0xffffff, alpha: 0.07), reactionInactiveBackground: UIColor(rgb: 0xffffff, alpha: 0.07),
reactionInactiveForeground: UIColor(rgb: 0xffffff), reactionInactiveForeground: UIColor(rgb: 0xffffff),
reactionActiveBackground: accentColor, reactionActiveBackground: accentColor,
reactionActiveForeground: UIColor(rgb: 0xffffff) reactionActiveForeground: monochrome ? UIColor(rgb: 0x000000) : UIColor(rgb: 0xffffff)
), ),
withoutWallpaper: chat.message.incoming.bubble.withoutWallpaper.withUpdated( withoutWallpaper: chat.message.incoming.bubble.withoutWallpaper.withUpdated(
reactionInactiveBackground: UIColor(rgb: 0xffffff, alpha: 0.07), reactionInactiveBackground: UIColor(rgb: 0xffffff, alpha: 0.07),
reactionInactiveForeground: UIColor(rgb: 0xffffff), reactionInactiveForeground: UIColor(rgb: 0xffffff),
reactionActiveBackground: accentColor, reactionActiveBackground: accentColor,
reactionActiveForeground: UIColor(rgb: 0xffffff) reactionActiveForeground: monochrome ? UIColor(rgb: 0x000000) : UIColor(rgb: 0xffffff)
) )
), ),
linkTextColor: accentColor, linkTextColor: accentColor,
@ -250,13 +250,13 @@ public func customizeDefaultDarkPresentationTheme(theme: PresentationTheme, edit
reactionInactiveBackground: UIColor(rgb: 0xffffff, alpha: 0.12), reactionInactiveBackground: UIColor(rgb: 0xffffff, alpha: 0.12),
reactionInactiveForeground: UIColor(rgb: 0xffffff), reactionInactiveForeground: UIColor(rgb: 0xffffff),
reactionActiveBackground: accentColor, reactionActiveBackground: accentColor,
reactionActiveForeground: UIColor(rgb: 0xffffff) reactionActiveForeground: monochrome ? UIColor(rgb: 0x000000) : UIColor(rgb: 0xffffff)
), ),
withoutWallpaper: chat.message.freeform.withoutWallpaper.withUpdated( withoutWallpaper: chat.message.freeform.withoutWallpaper.withUpdated(
reactionInactiveBackground: chat.message.incoming.bubble.withoutWallpaper.fill.last, reactionInactiveBackground: chat.message.incoming.bubble.withoutWallpaper.fill.last,
reactionInactiveForeground: UIColor(rgb: 0xffffff), reactionInactiveForeground: UIColor(rgb: 0xffffff),
reactionActiveBackground: accentColor, reactionActiveBackground: accentColor,
reactionActiveForeground: UIColor(rgb: 0xffffff) reactionActiveForeground: monochrome ? UIColor(rgb: 0x000000) : UIColor(rgb: 0xffffff)
) )
), ),
infoLinkTextColor: accentColor, infoLinkTextColor: accentColor,

View File

@ -6853,7 +6853,16 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
media = .keep media = .keep
} }
let _ = (strongSelf.context.account.postbox.messageAtId(editMessage.messageId)
|> deliverOnMainQueue)
.start(next: { [weak self] currentMessage in
if let strongSelf = self {
if let currentMessage = currentMessage {
let currentEntities = currentMessage.textEntitiesAttribute?.entities ?? []
if currentMessage.text != text.string || currentEntities != entities {
strongSelf.context.account.pendingUpdateMessageManager.add(messageId: editMessage.messageId, text: text.string, media: media, entities: entitiesAttribute, disableUrlPreview: disableUrlPreview) strongSelf.context.account.pendingUpdateMessageManager.add(messageId: editMessage.messageId, text: text.string, media: media, entities: entitiesAttribute, disableUrlPreview: disableUrlPreview)
}
}
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { state in strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { state in
var state = state var state = state
@ -6862,6 +6871,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
return state return state
}) })
} }
})
}
}, beginMessageSearch: { [weak self] domain, query in }, beginMessageSearch: { [weak self] domain, query in
guard let strongSelf = self else { guard let strongSelf = self else {
return return

View File

@ -182,8 +182,6 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
let factor: CGFloat = max(0.0, min(1.0, (scale - 1.0) * 8.0)) let factor: CGFloat = max(0.0, min(1.0, (scale - 1.0) * 8.0))
transition.updateAlpha(node: strongSelf.dateAndStatusNode, alpha: 1.0 - factor)
if abs(scale - 1.0) > CGFloat.ulpOfOne { if abs(scale - 1.0) > CGFloat.ulpOfOne {
var highQualityImageNode: TransformImageNode? var highQualityImageNode: TransformImageNode?
if let current = strongSelf.highQualityImageNode { if let current = strongSelf.highQualityImageNode {
@ -241,6 +239,7 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
}) })
} }
transition.updateAlpha(node: strongSelf.dateAndStatusNode, alpha: 1.0 - factor)
if let badgeNode = strongSelf.badgeNode { if let badgeNode = strongSelf.badgeNode {
transition.updateAlpha(node: badgeNode, alpha: 1.0 - factor) transition.updateAlpha(node: badgeNode, alpha: 1.0 - factor)
} }
@ -1614,6 +1613,14 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
statusNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2) statusNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
} }
} }
if self.dateAndStatusNode.isHidden != isHidden {
if isHidden {
self.dateAndStatusNode.isHidden = true
} else {
self.dateAndStatusNode.isHidden = false
self.dateAndStatusNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
}
}
} }
func transitionNode() -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? { func transitionNode() -> (ASDisplayNode, CGRect, () -> (UIView?, UIView?))? {
@ -1634,6 +1641,11 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
statusNodeHidden = statusNode.isHidden statusNodeHidden = statusNode.isHidden
statusNode.isHidden = true statusNode.isHidden = true
} }
var dateAndStatusNodeHidden: Bool?
if let dateAndStatusNode = self?.dateAndStatusNode {
dateAndStatusNodeHidden = dateAndStatusNode.isHidden
dateAndStatusNode.isHidden = true
}
let view: UIView? let view: UIView?
if let strongSelf = self, strongSelf.imageNode.captureProtected { if let strongSelf = self, strongSelf.imageNode.captureProtected {
@ -1658,6 +1670,9 @@ final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTransitio
if let statusNode = self?.statusNode, let statusNodeHidden = statusNodeHidden { if let statusNode = self?.statusNode, let statusNodeHidden = statusNodeHidden {
statusNode.isHidden = statusNodeHidden statusNode.isHidden = statusNodeHidden
} }
if let dateAndStatusNode = self?.dateAndStatusNode, let dateAndStatusNodeHidden = dateAndStatusNodeHidden {
dateAndStatusNode.isHidden = dateAndStatusNodeHidden
}
return (view, nil) return (view, nil)
}) })
} }

View File

@ -235,6 +235,8 @@ private enum CreateGroupEntry: ItemListNodeEntry {
case let .groupInfo(_, _, dateTimeFormat, peer, state, avatar): case let .groupInfo(_, _, dateTimeFormat, peer, state, avatar):
return ItemListAvatarAndNameInfoItem(accountContext: arguments.context, presentationData: presentationData, dateTimeFormat: dateTimeFormat, mode: .editSettings, peer: peer.flatMap(EnginePeer.init), presence: nil, memberCount: nil, state: state, sectionId: ItemListSectionId(self.section), style: .blocks(withTopInset: false, withExtendedBottomInset: false), editingNameUpdated: { editingName in return ItemListAvatarAndNameInfoItem(accountContext: arguments.context, presentationData: presentationData, dateTimeFormat: dateTimeFormat, mode: .editSettings, peer: peer.flatMap(EnginePeer.init), presence: nil, memberCount: nil, state: state, sectionId: ItemListSectionId(self.section), style: .blocks(withTopInset: false, withExtendedBottomInset: false), editingNameUpdated: { editingName in
arguments.updateEditingName(editingName) arguments.updateEditingName(editingName)
}, editingNameCompleted: {
arguments.done()
}, avatarTapped: { }, avatarTapped: {
arguments.changeProfilePhoto() arguments.changeProfilePhoto()
}, updatingImage: avatar, tag: CreateGroupEntryTag.info) }, updatingImage: avatar, tag: CreateGroupEntryTag.info)