mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Reaction improvements
This commit is contained in:
parent
9b9f57f019
commit
b983de1abf
@ -1323,6 +1323,30 @@ open class NavigationController: UINavigationController, ContainableController,
|
||||
}
|
||||
|
||||
open override func setViewControllers(_ viewControllers: [UIViewController], animated: Bool) {
|
||||
for i in 0 ..< viewControllers.count {
|
||||
guard let controller = viewControllers[i] as? ViewController else {
|
||||
continue
|
||||
}
|
||||
if self.viewControllers.contains(where: { $0 === controller }) {
|
||||
continue
|
||||
}
|
||||
if let customNavigationData = controller.customNavigationData {
|
||||
var found = false
|
||||
for previousIndex in (0 ..< self.viewControllers.count).reversed() {
|
||||
let previousController = self.viewControllers[previousIndex]
|
||||
|
||||
if let previousController = previousController as? ViewController, let previousCustomNavigationDataSummary = previousController.customNavigationDataSummary {
|
||||
controller.customNavigationDataSummary = customNavigationData.combine(summary: previousCustomNavigationDataSummary)
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
controller.customNavigationDataSummary = customNavigationData.combine(summary: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self._viewControllers = viewControllers.map { controller in
|
||||
let controller = controller as! ViewController
|
||||
controller.navigation_setNavigationController(self)
|
||||
|
@ -73,6 +73,13 @@ public enum TabBarItemContextActionType {
|
||||
case whenActive
|
||||
}
|
||||
|
||||
public protocol CustomViewControllerNavigationData: AnyObject {
|
||||
func combine(summary: CustomViewControllerNavigationDataSummary?) -> CustomViewControllerNavigationDataSummary?
|
||||
}
|
||||
|
||||
public protocol CustomViewControllerNavigationDataSummary: AnyObject {
|
||||
}
|
||||
|
||||
@objc open class ViewController: UIViewController, ContainableController {
|
||||
public struct NavigationLayout {
|
||||
public var navigationFrame: CGRect
|
||||
@ -274,6 +281,13 @@ public enum TabBarItemContextActionType {
|
||||
}
|
||||
}
|
||||
|
||||
open var customNavigationData: CustomViewControllerNavigationData? {
|
||||
get {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
open var customNavigationDataSummary: CustomViewControllerNavigationDataSummary?
|
||||
|
||||
public internal(set) var isInFocus: Bool = false {
|
||||
didSet {
|
||||
if self.isInFocus != oldValue {
|
||||
|
@ -1868,9 +1868,9 @@ public final class AccountViewTracker {
|
||||
}
|
||||
}
|
||||
var reactionCount: Int32 = 0
|
||||
if let view = views.views[pendingReactionsKey] as? PendingMessageActionsSummaryView {
|
||||
/*if let view = views.views[pendingReactionsKey] as? PendingMessageActionsSummaryView {
|
||||
reactionCount -= view.count
|
||||
}
|
||||
}*/
|
||||
if let view = views.views[summaryReactionsKey] as? MessageHistoryTagSummaryView {
|
||||
if let unseenCount = view.count {
|
||||
reactionCount += unseenCount
|
||||
|
@ -231,7 +231,7 @@ extension EngineChatList.Item {
|
||||
tag: .unseenReaction,
|
||||
actionType: PendingMessageActionType.readReaction
|
||||
)] {
|
||||
hasUnseenReactions = (info.tagSummaryCount ?? 0) > (info.actionsSummaryCount ?? 0)
|
||||
hasUnseenReactions = (info.tagSummaryCount ?? 0) != 0// > (info.actionsSummaryCount ?? 0)
|
||||
}
|
||||
|
||||
self.init(
|
||||
|
@ -15,6 +15,9 @@ func _internal_earliestUnseenPersonalMentionMessage(account: Account, peerId: Pe
|
||||
if view.0.isLoading {
|
||||
return .single(.loading)
|
||||
}
|
||||
if case .FillHole = view.1 {
|
||||
return _internal_earliestUnseenPersonalMentionMessage(account: account, peerId: peerId)
|
||||
}
|
||||
if let message = view.0.entries.first?.message {
|
||||
if peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||
var invalidatedPts: Int32?
|
||||
@ -79,6 +82,9 @@ func _internal_earliestUnseenPersonalReactionMessage(account: Account, peerId: P
|
||||
if view.0.isLoading {
|
||||
return .single(.loading)
|
||||
}
|
||||
if case .FillHole = view.1 {
|
||||
return _internal_earliestUnseenPersonalReactionMessage(account: account, peerId: peerId)
|
||||
}
|
||||
if let message = view.0.entries.first?.message {
|
||||
if peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||
var invalidatedPts: Int32?
|
||||
|
@ -7,6 +7,7 @@ func _internal_installInteractiveReadMessagesAction(postbox: Postbox, stateManag
|
||||
return postbox.installStoreMessageAction(peerId: peerId, { messages, transaction in
|
||||
var consumeMessageIds: [MessageId] = []
|
||||
var readReactionIds: [MessageId] = []
|
||||
readReactionIds.removeAll()
|
||||
|
||||
var readMessageIndexByNamespace: [MessageId.Namespace: MessageIndex] = [:]
|
||||
|
||||
@ -32,7 +33,7 @@ func _internal_installInteractiveReadMessagesAction(postbox: Postbox, stateManag
|
||||
consumeMessageIds.append(id)
|
||||
}
|
||||
if hasUnseenReactions {
|
||||
readReactionIds.append(id)
|
||||
//readReactionIds.append(id)
|
||||
}
|
||||
|
||||
if !message.flags.intersection(.IsIncomingMask).isEmpty {
|
||||
@ -56,6 +57,7 @@ func _internal_installInteractiveReadMessagesAction(postbox: Postbox, stateManag
|
||||
}
|
||||
}
|
||||
}
|
||||
var tags = currentMessage.tags
|
||||
if readReactionIds.contains(id) {
|
||||
reactionsLoop: for j in 0 ..< attributes.count {
|
||||
if let attribute = attributes[j] as? ReactionsMessageAttribute {
|
||||
@ -63,9 +65,8 @@ func _internal_installInteractiveReadMessagesAction(postbox: Postbox, stateManag
|
||||
break reactionsLoop
|
||||
}
|
||||
}
|
||||
tags.remove(.unseenReaction)
|
||||
}
|
||||
var tags = currentMessage.tags
|
||||
tags.remove(.unseenReaction)
|
||||
return .update(StoreMessage(id: currentMessage.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, threadId: currentMessage.threadId, timestamp: currentMessage.timestamp, flags: StoreMessageFlags(currentMessage.flags), tags: tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: currentMessage.forwardInfo.flatMap(StoreMessageForwardInfo.init), authorId: currentMessage.author?.id, text: currentMessage.text, attributes: attributes, media: currentMessage.media))
|
||||
})
|
||||
|
||||
|
@ -475,6 +475,16 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
return self.chatLocation
|
||||
}
|
||||
|
||||
override public var customNavigationData: CustomViewControllerNavigationData? {
|
||||
get {
|
||||
if case let .peer(peerId) = self.chatLocation {
|
||||
return ChatControllerNavigationData(peerId: peerId)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var scheduledScrollToMessageId: (MessageId, Double?)?
|
||||
|
||||
public var purposefulAction: (() -> Void)?
|
||||
@ -8498,14 +8508,20 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
})
|
||||
}
|
||||
|
||||
if !self.chatNavigationStack.isEmpty {
|
||||
var chatNavigationStack: [PeerId] = self.chatNavigationStack
|
||||
if case let .peer(peerId) = self.chatLocation, let summary = self.customNavigationDataSummary as? ChatControllerNavigationDataSummary {
|
||||
chatNavigationStack.removeAll()
|
||||
chatNavigationStack = summary.peerIds.filter({ $0 != peerId })
|
||||
}
|
||||
|
||||
if !chatNavigationStack.isEmpty {
|
||||
self.chatDisplayNode.navigationBar?.backButtonNode.isGestureEnabled = true
|
||||
self.chatDisplayNode.navigationBar?.backButtonNode.activated = { [weak self] gesture, _ in
|
||||
guard let strongSelf = self else {
|
||||
gesture.cancel()
|
||||
return
|
||||
}
|
||||
let chatNavigationStack = strongSelf.chatNavigationStack
|
||||
|
||||
let _ = (strongSelf.context.account.postbox.transaction { transaction -> [Peer] in
|
||||
return chatNavigationStack.compactMap(transaction.getPeer)
|
||||
}
|
||||
@ -8525,10 +8541,10 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
return
|
||||
}
|
||||
|
||||
let snapshotState = strongSelf.chatDisplayNode.prepareSnapshotState(
|
||||
/*let snapshotState = strongSelf.chatDisplayNode.prepareSnapshotState(
|
||||
titleViewSnapshotState: strongSelf.chatTitleView?.prepareSnapshotState(),
|
||||
avatarSnapshotState: (strongSelf.chatInfoNavigationButton?.buttonItem.customDisplayNode as? ChatAvatarNavigationNode)?.prepareSnapshotState()
|
||||
)
|
||||
)*/
|
||||
|
||||
let nextFolderId: Int32? = strongSelf.currentChatListFilter
|
||||
|
||||
@ -8537,8 +8553,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
updatedChatNavigationStack.removeSubrange(0 ..< (index + 1))
|
||||
}
|
||||
|
||||
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(peer.id), animated: false, chatListFilter: nextFolderId, chatNavigationStack: updatedChatNavigationStack, completion: { nextController in
|
||||
(nextController as! ChatControllerImpl).animateFromPreviousController(snapshotState: snapshotState)
|
||||
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(peer.id), animated: true, chatListFilter: nextFolderId, chatNavigationStack: updatedChatNavigationStack, completion: { nextController in
|
||||
let _ = nextController
|
||||
//(nextController as! ChatControllerImpl).animateFromPreviousController(snapshotState: snapshotState)
|
||||
}))
|
||||
})))
|
||||
}
|
||||
@ -14832,3 +14849,34 @@ func peerAllowedReactions(context: AccountContext, peerId: PeerId) -> Signal<All
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final class ChatControllerNavigationData: CustomViewControllerNavigationData {
|
||||
let peerId: PeerId
|
||||
|
||||
init(peerId: PeerId) {
|
||||
self.peerId = peerId
|
||||
}
|
||||
|
||||
func combine(summary: CustomViewControllerNavigationDataSummary?) -> CustomViewControllerNavigationDataSummary? {
|
||||
if let summary = summary as? ChatControllerNavigationDataSummary {
|
||||
return summary.adding(peerId: self.peerId)
|
||||
} else {
|
||||
return ChatControllerNavigationDataSummary(peerIds: [self.peerId])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final class ChatControllerNavigationDataSummary: CustomViewControllerNavigationDataSummary {
|
||||
let peerIds: [PeerId]
|
||||
|
||||
init(peerIds: [PeerId]) {
|
||||
self.peerIds = peerIds
|
||||
}
|
||||
|
||||
func adding(peerId: PeerId) -> ChatControllerNavigationDataSummary {
|
||||
var peerIds = self.peerIds
|
||||
peerIds.removeAll(where: { $0 == peerId })
|
||||
peerIds.insert(peerId, at: 0)
|
||||
return ChatControllerNavigationDataSummary(peerIds: peerIds)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user