mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
c94ef88deb
commit
f38d77a985
@ -818,12 +818,12 @@ private func channelVisibilityControllerEntries(presentationData: PresentationDa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if isGroup && selectedType == .publicChannel {
|
var isDiscussion = false
|
||||||
var isDiscussion = false
|
if let cachedData = view.cachedData as? CachedChannelData, case .known = cachedData.linkedDiscussionPeerId {
|
||||||
if let cachedData = view.cachedData as? CachedChannelData, case .known = cachedData.linkedDiscussionPeerId {
|
isDiscussion = true
|
||||||
isDiscussion = true
|
}
|
||||||
}
|
|
||||||
|
if isGroup && (selectedType == .publicChannel || isDiscussion) {
|
||||||
if isDiscussion {
|
if isDiscussion {
|
||||||
entries.append(.joinToSendHeader(presentationData.theme, presentationData.strings.Group_Setup_WhoCanSendMessages_Title.uppercased()))
|
entries.append(.joinToSendHeader(presentationData.theme, presentationData.strings.Group_Setup_WhoCanSendMessages_Title.uppercased()))
|
||||||
entries.append(.joinToSendEveryone(presentationData.theme, presentationData.strings.Group_Setup_WhoCanSendMessages_Everyone, joinToSend == .everyone))
|
entries.append(.joinToSendEveryone(presentationData.theme, presentationData.strings.Group_Setup_WhoCanSendMessages_Everyone, joinToSend == .everyone))
|
||||||
|
@ -75,7 +75,6 @@ func chatHistoryEntriesForView(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var groupBucket: [(Message, Bool, ChatHistoryMessageSelection, ChatMessageEntryAttributes, MessageHistoryEntryLocation?)] = []
|
var groupBucket: [(Message, Bool, ChatHistoryMessageSelection, ChatMessageEntryAttributes, MessageHistoryEntryLocation?)] = []
|
||||||
var count = 0
|
var count = 0
|
||||||
loop: for entry in view.entries {
|
loop: for entry in view.entries {
|
||||||
|
@ -49,7 +49,7 @@ public enum ChatHistoryListMode: Equatable {
|
|||||||
enum ChatHistoryViewScrollPosition {
|
enum ChatHistoryViewScrollPosition {
|
||||||
case unread(index: MessageIndex)
|
case unread(index: MessageIndex)
|
||||||
case positionRestoration(index: MessageIndex, relativeOffset: CGFloat)
|
case positionRestoration(index: MessageIndex, relativeOffset: CGFloat)
|
||||||
case index(index: MessageHistoryAnchorIndex, position: ListViewScrollPosition, directionHint: ListViewScrollToItemDirectionHint, animated: Bool, highlight: Bool)
|
case index(index: MessageHistoryAnchorIndex, position: ListViewScrollPosition, directionHint: ListViewScrollToItemDirectionHint, animated: Bool, highlight: Bool, displayLink: Bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ChatHistoryViewUpdateType {
|
enum ChatHistoryViewUpdateType {
|
||||||
@ -800,7 +800,7 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
|
|||||||
|
|
||||||
let scrollPosition: ChatHistoryViewScrollPosition?
|
let scrollPosition: ChatHistoryViewScrollPosition?
|
||||||
if isFirstTime, let messageIndex = messages.first(where: { $0.id == at })?.index {
|
if isFirstTime, let messageIndex = messages.first(where: { $0.id == at })?.index {
|
||||||
scrollPosition = .index(index: .message(messageIndex), position: .center(.bottom), directionHint: .Down, animated: false, highlight: false)
|
scrollPosition = .index(index: .message(messageIndex), position: .center(.bottom), directionHint: .Down, animated: false, highlight: false, displayLink: false)
|
||||||
isFirstTime = false
|
isFirstTime = false
|
||||||
} else {
|
} else {
|
||||||
scrollPosition = nil
|
scrollPosition = nil
|
||||||
@ -1183,10 +1183,10 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
|
|||||||
|
|
||||||
if scrollPosition == nil, let originalScrollPosition = originalScrollPosition {
|
if scrollPosition == nil, let originalScrollPosition = originalScrollPosition {
|
||||||
switch originalScrollPosition {
|
switch originalScrollPosition {
|
||||||
case let .index(index, position, _, _, highlight):
|
case let .index(index, position, _, _, highlight, displayLink):
|
||||||
if case .upperBound = index {
|
if case .upperBound = index {
|
||||||
if let previous = previous, previous.filteredEntries.isEmpty {
|
if let previous = previous, previous.filteredEntries.isEmpty {
|
||||||
updatedScrollPosition = .index(index: index, position: position, directionHint: .Down, animated: false, highlight: highlight)
|
updatedScrollPosition = .index(index: index, position: position, directionHint: .Down, animated: false, highlight: highlight, displayLink: displayLink)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -1226,7 +1226,7 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
|
|||||||
if isFirstTime {
|
if isFirstTime {
|
||||||
} else if case let .peer(peerId) = chatLocation, currentlyPlayingMessageId.id.peerId != peerId {
|
} else if case let .peer(peerId) = chatLocation, currentlyPlayingMessageId.id.peerId != peerId {
|
||||||
} else {
|
} else {
|
||||||
updatedScrollPosition = .index(index: .message(currentlyPlayingMessageId), position: .center(.bottom), directionHint: .Up, animated: true, highlight: true)
|
updatedScrollPosition = .index(index: .message(currentlyPlayingMessageId), position: .center(.bottom), directionHint: .Up, animated: true, highlight: true, displayLink: true)
|
||||||
scrollAnimationCurve = .Spring(duration: 0.4)
|
scrollAnimationCurve = .Spring(duration: 0.4)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1270,7 +1270,7 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if fillsScreen, let firstNonAdIndex = firstNonAdIndex, previousNumAds == 0, updatedNumAds != 0 {
|
if fillsScreen, let firstNonAdIndex = firstNonAdIndex, previousNumAds == 0, updatedNumAds != 0 {
|
||||||
updatedScrollPosition = .index(index: .message(firstNonAdIndex), position: .top(0.0), directionHint: .Up, animated: false, highlight: false)
|
updatedScrollPosition = .index(index: .message(firstNonAdIndex), position: .top(0.0), directionHint: .Up, animated: false, highlight: false, displayLink: false)
|
||||||
disableAnimations = true
|
disableAnimations = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ func chatHistoryViewForLocation(_ location: ChatHistoryLocationInput, ignoreMess
|
|||||||
var chatScrollPosition: ChatHistoryViewScrollPosition?
|
var chatScrollPosition: ChatHistoryViewScrollPosition?
|
||||||
if case let .Scroll(index, _, sourceIndex, position, animated, highlight) = location.content {
|
if case let .Scroll(index, _, sourceIndex, position, animated, highlight) = location.content {
|
||||||
let directionHint: ListViewScrollToItemDirectionHint = sourceIndex > index ? .Down : .Up
|
let directionHint: ListViewScrollToItemDirectionHint = sourceIndex > index ? .Down : .Up
|
||||||
chatScrollPosition = .index(index: index, position: position, directionHint: directionHint, animated: animated, highlight: highlight)
|
chatScrollPosition = .index(index: index, position: position, directionHint: directionHint, animated: animated, highlight: highlight, displayLink: false)
|
||||||
}
|
}
|
||||||
return account.viewTracker.scheduledMessagesViewForLocation(context.chatLocationInput(for: chatLocation, contextHolder: chatLocationContextHolder), additionalData: additionalData)
|
return account.viewTracker.scheduledMessagesViewForLocation(context.chatLocationInput(for: chatLocation, contextHolder: chatLocationContextHolder), additionalData: additionalData)
|
||||||
|> map { view, updateType, initialData -> ChatHistoryViewUpdate in
|
|> map { view, updateType, initialData -> ChatHistoryViewUpdate in
|
||||||
@ -220,7 +220,7 @@ func chatHistoryViewForLocation(_ location: ChatHistoryLocationInput, ignoreMess
|
|||||||
}
|
}
|
||||||
|
|
||||||
preloaded = true
|
preloaded = true
|
||||||
return .HistoryView(view: view, type: reportUpdateType, scrollPosition: .index(index: anchorIndex, position: .center(.bottom), directionHint: .Down, animated: false, highlight: highlight), flashIndicators: false, originalScrollPosition: nil, initialData: ChatHistoryCombinedInitialData(initialData: initialData, buttonKeyboardMessage: view.topTaggedMessages.first, cachedData: cachedData, cachedDataMessages: cachedDataMessages, readStateData: readStateData), id: location.id)
|
return .HistoryView(view: view, type: reportUpdateType, scrollPosition: .index(index: anchorIndex, position: .center(.bottom), directionHint: .Down, animated: false, highlight: highlight, displayLink: false), flashIndicators: false, originalScrollPosition: nil, initialData: ChatHistoryCombinedInitialData(initialData: initialData, buttonKeyboardMessage: view.topTaggedMessages.first, cachedData: cachedData, cachedDataMessages: cachedDataMessages, readStateData: readStateData), id: location.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case let .Navigation(index, anchorIndex, count, _):
|
case let .Navigation(index, anchorIndex, count, _):
|
||||||
@ -239,7 +239,7 @@ func chatHistoryViewForLocation(_ location: ChatHistoryLocationInput, ignoreMess
|
|||||||
}
|
}
|
||||||
case let .Scroll(index, anchorIndex, sourceIndex, scrollPosition, animated, highlight):
|
case let .Scroll(index, anchorIndex, sourceIndex, scrollPosition, animated, highlight):
|
||||||
let directionHint: ListViewScrollToItemDirectionHint = sourceIndex > index ? .Down : .Up
|
let directionHint: ListViewScrollToItemDirectionHint = sourceIndex > index ? .Down : .Up
|
||||||
let chatScrollPosition = ChatHistoryViewScrollPosition.index(index: index, position: scrollPosition, directionHint: directionHint, animated: animated, highlight: highlight)
|
let chatScrollPosition = ChatHistoryViewScrollPosition.index(index: index, position: scrollPosition, directionHint: directionHint, animated: animated, highlight: highlight, displayLink: false)
|
||||||
var first = true
|
var first = true
|
||||||
return account.viewTracker.aroundMessageHistoryViewForLocation(context.chatLocationInput(for: chatLocation, contextHolder: chatLocationContextHolder), ignoreMessagesInTimestampRange: ignoreMessagesInTimestampRange, index: index, anchorIndex: anchorIndex, count: 128, ignoreRelatedChats: ignoreRelatedChats, fixedCombinedReadStates: fixedCombinedReadStates, tagMask: tagMask, appendMessagesFromTheSameGroup: appendMessagesFromTheSameGroup, orderStatistics: orderStatistics, additionalData: additionalData)
|
return account.viewTracker.aroundMessageHistoryViewForLocation(context.chatLocationInput(for: chatLocation, contextHolder: chatLocationContextHolder), ignoreMessagesInTimestampRange: ignoreMessagesInTimestampRange, index: index, anchorIndex: anchorIndex, count: 128, ignoreRelatedChats: ignoreRelatedChats, fixedCombinedReadStates: fixedCombinedReadStates, tagMask: tagMask, appendMessagesFromTheSameGroup: appendMessagesFromTheSameGroup, orderStatistics: orderStatistics, additionalData: additionalData)
|
||||||
|> map { view, updateType, initialData -> ChatHistoryViewUpdate in
|
|> map { view, updateType, initialData -> ChatHistoryViewUpdate in
|
||||||
|
@ -34,7 +34,7 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
|
|||||||
private var appliedItem: ChatMessageItem?
|
private var appliedItem: ChatMessageItem?
|
||||||
private var appliedForwardInfo: (Peer?, String?)?
|
private var appliedForwardInfo: (Peer?, String?)?
|
||||||
private var appliedHasAvatar = false
|
private var appliedHasAvatar = false
|
||||||
private var appliedCurrentlyPlaying = false
|
private var appliedCurrentlyPlaying: Bool?
|
||||||
private var appliedAutomaticDownload = false
|
private var appliedAutomaticDownload = false
|
||||||
private var avatarOffset: CGFloat?
|
private var avatarOffset: CGFloat?
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
|
|||||||
if !strongSelf.interactiveVideoNode.frame.contains(location) {
|
if !strongSelf.interactiveVideoNode.frame.contains(location) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if strongSelf.appliedCurrentlyPlaying && !strongSelf.interactiveVideoNode.isPlaying {
|
if (strongSelf.appliedCurrentlyPlaying ?? false) && !strongSelf.interactiveVideoNode.isPlaying {
|
||||||
return strongSelf.interactiveVideoNode.frame.insetBy(dx: 0.15 * strongSelf.interactiveVideoNode.frame.width, dy: 0.15 * strongSelf.interactiveVideoNode.frame.height).contains(location)
|
return strongSelf.interactiveVideoNode.frame.insetBy(dx: 0.15 * strongSelf.interactiveVideoNode.frame.width, dy: 0.15 * strongSelf.interactiveVideoNode.frame.height).contains(location)
|
||||||
}
|
}
|
||||||
if let action = strongSelf.gestureRecognized(gesture: .tap, location: location, recognizer: nil) {
|
if let action = strongSelf.gestureRecognized(gesture: .tap, location: location, recognizer: nil) {
|
||||||
@ -127,7 +127,7 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
|
|||||||
case let .openContextMenu(tapMessage, selectAll, subFrame):
|
case let .openContextMenu(tapMessage, selectAll, subFrame):
|
||||||
strongSelf.recognizer?.cancel()
|
strongSelf.recognizer?.cancel()
|
||||||
item.controllerInteraction.openMessageContextMenu(tapMessage, selectAll, strongSelf, subFrame, gesture)
|
item.controllerInteraction.openMessageContextMenu(tapMessage, selectAll, strongSelf, subFrame, gesture)
|
||||||
if strongSelf.appliedCurrentlyPlaying && strongSelf.interactiveVideoNode.isPlaying {
|
if (strongSelf.appliedCurrentlyPlaying ?? false) && strongSelf.interactiveVideoNode.isPlaying {
|
||||||
strongSelf.wasPlaying = true
|
strongSelf.wasPlaying = true
|
||||||
strongSelf.interactiveVideoNode.pause()
|
strongSelf.interactiveVideoNode.pause()
|
||||||
}
|
}
|
||||||
@ -199,7 +199,7 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
|
|||||||
if strongSelf.selectionNode != nil {
|
if strongSelf.selectionNode != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if strongSelf.appliedCurrentlyPlaying && !strongSelf.interactiveVideoNode.isPlaying {
|
if (strongSelf.appliedCurrentlyPlaying ?? false) && !strongSelf.interactiveVideoNode.isPlaying {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
let action = item.controllerInteraction.canSetupReply(item.message)
|
let action = item.controllerInteraction.canSetupReply(item.message)
|
||||||
@ -1098,7 +1098,7 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
|
|||||||
selected = selectionState.selectedIds.contains(item.message.id)
|
selected = selectionState.selectedIds.contains(item.message.id)
|
||||||
incoming = item.message.effectivelyIncoming(item.context.account.peerId)
|
incoming = item.message.effectivelyIncoming(item.context.account.peerId)
|
||||||
|
|
||||||
let offset: CGFloat = incoming || self.appliedCurrentlyPlaying ? 42.0 : 0.0
|
let offset: CGFloat = incoming || (self.appliedCurrentlyPlaying ?? false) ? 42.0 : 0.0
|
||||||
|
|
||||||
if let selectionNode = self.selectionNode {
|
if let selectionNode = self.selectionNode {
|
||||||
let selectionFrame = CGRect(origin: CGPoint(x: -offset, y: 0.0), size: CGSize(width: self.contentBounds.size.width, height: self.contentBounds.size.height))
|
let selectionFrame = CGRect(origin: CGPoint(x: -offset, y: 0.0), size: CGSize(width: self.contentBounds.size.width, height: self.contentBounds.size.height))
|
||||||
|
@ -885,15 +885,19 @@ public class ChatMessageItemView: ListViewItemNode, ChatMessageItemNodeProtocol
|
|||||||
private var attachedAvatarNodeOffset: CGFloat = 0.0
|
private var attachedAvatarNodeOffset: CGFloat = 0.0
|
||||||
|
|
||||||
override public func attachedHeaderNodesUpdated() {
|
override public func attachedHeaderNodesUpdated() {
|
||||||
self.updateAttachedAvatarNodeOffset(offset: self.attachedAvatarNodeOffset, transition: .immediate)
|
if !self.attachedAvatarNodeOffset.isZero {
|
||||||
for headerNode in self.attachedHeaderNodes {
|
self.updateAttachedAvatarNodeOffset(offset: self.attachedAvatarNodeOffset, transition: .immediate)
|
||||||
if let headerNode = headerNode as? ChatMessageAvatarHeaderNode {
|
} else {
|
||||||
headerNode.updateSelectionState(animated: false)
|
for headerNode in self.attachedHeaderNodes {
|
||||||
|
if let headerNode = headerNode as? ChatMessageAvatarHeaderNode {
|
||||||
|
headerNode.updateSelectionState(animated: false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateAttachedAvatarNodeOffset(offset: CGFloat, transition: ContainedViewLayoutTransition) {
|
func updateAttachedAvatarNodeOffset(offset: CGFloat, transition: ContainedViewLayoutTransition) {
|
||||||
|
self.attachedAvatarNodeOffset = offset
|
||||||
for headerNode in self.attachedHeaderNodes {
|
for headerNode in self.attachedHeaderNodes {
|
||||||
if let headerNode = headerNode as? ChatMessageAvatarHeaderNode {
|
if let headerNode = headerNode as? ChatMessageAvatarHeaderNode {
|
||||||
transition.updateSublayerTransformOffset(layer: headerNode.layer, offset: CGPoint(x: offset, y: 0.0))
|
transition.updateSublayerTransformOffset(layer: headerNode.layer, offset: CGPoint(x: offset, y: 0.0))
|
||||||
|
@ -191,14 +191,14 @@ func preparedChatHistoryViewTransition(from fromView: ChatHistoryView?, to toVie
|
|||||||
index += 1
|
index += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case let .index(scrollIndex, position, directionHint, animated, highlight):
|
case let .index(scrollIndex, position, directionHint, animated, highlight, displayLink):
|
||||||
if case .center = position, highlight {
|
if case .center = position, highlight {
|
||||||
scrolledToIndex = scrollIndex
|
scrolledToIndex = scrollIndex
|
||||||
}
|
}
|
||||||
var index = toView.filteredEntries.count - 1
|
var index = toView.filteredEntries.count - 1
|
||||||
for entry in toView.filteredEntries {
|
for entry in toView.filteredEntries {
|
||||||
if scrollIndex.isLessOrEqual(to: entry.index) {
|
if scrollIndex.isLessOrEqual(to: entry.index) {
|
||||||
scrollToItem = ListViewScrollToItem(index: index, position: position, animated: animated, curve: curve, directionHint: directionHint)
|
scrollToItem = ListViewScrollToItem(index: index, position: position, animated: animated, curve: curve, directionHint: directionHint, displayLink: displayLink)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
index -= 1
|
index -= 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user