mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2026-01-17 09:51:20 +00:00
Recommended channel fixes
This commit is contained in:
@@ -100,7 +100,7 @@ private enum ChatListRecentEntry: Comparable, Identifiable {
|
||||
presentationData: ChatListPresentationData,
|
||||
filter: ChatListNodePeersFilter,
|
||||
key: ChatListSearchPaneKey,
|
||||
peerSelected: @escaping (EnginePeer, Int64?) -> Void,
|
||||
peerSelected: @escaping (EnginePeer, Int64?, Bool) -> Void,
|
||||
disabledPeerSelected: @escaping (EnginePeer, Int64?, ChatListDisabledPeerReason) -> Void,
|
||||
peerContextAction: ((EnginePeer, ChatListSearchContextActionSource, ASDisplayNode, ContextGesture?, CGPoint?) -> Void)?,
|
||||
clearRecentlySearchedPeers: @escaping () -> Void,
|
||||
@@ -114,7 +114,7 @@ private enum ChatListRecentEntry: Comparable, Identifiable {
|
||||
switch self {
|
||||
case let .topPeers(peers, theme, strings):
|
||||
return ChatListRecentPeersListItem(theme: theme, strings: strings, context: context, peers: peers, peerSelected: { peer in
|
||||
peerSelected(peer, nil)
|
||||
peerSelected(peer, nil, false)
|
||||
}, peerContextAction: { peer, node, gesture, location in
|
||||
if let peerContextAction = peerContextAction {
|
||||
peerContextAction(peer, .recentPeers, node, gesture, location)
|
||||
@@ -267,7 +267,7 @@ private enum ChatListRecentEntry: Comparable, Identifiable {
|
||||
header: header,
|
||||
action: { _ in
|
||||
if let chatPeer = peer.peer.peers[peer.peer.peerId] {
|
||||
peerSelected(EnginePeer(chatPeer), nil)
|
||||
peerSelected(EnginePeer(chatPeer), nil, section == .recommendedChannels)
|
||||
}
|
||||
},
|
||||
disabledAction: { _ in
|
||||
@@ -969,7 +969,7 @@ private func chatListSearchContainerPreparedRecentTransition(
|
||||
presentationData: ChatListPresentationData,
|
||||
filter: ChatListNodePeersFilter,
|
||||
key: ChatListSearchPaneKey,
|
||||
peerSelected: @escaping (EnginePeer, Int64?) -> Void,
|
||||
peerSelected: @escaping (EnginePeer, Int64?, Bool) -> Void,
|
||||
disabledPeerSelected: @escaping (EnginePeer, Int64?, ChatListDisabledPeerReason) -> Void,
|
||||
peerContextAction: ((EnginePeer, ChatListSearchContextActionSource, ASDisplayNode, ContextGesture?, CGPoint?) -> Void)?,
|
||||
clearRecentlySearchedPeers: @escaping () -> Void,
|
||||
@@ -1790,7 +1790,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
|
||||
|> then(
|
||||
context.engine.contacts.searchRemotePeers(query: query)
|
||||
|> map { ($0.0, $0.1, false) }
|
||||
|> delay(0.2, queue: Queue.concurrentDefaultQueue())
|
||||
|> delay(0.4, queue: Queue.concurrentDefaultQueue())
|
||||
)
|
||||
)
|
||||
} else if let query = query, case .channels = key {
|
||||
@@ -1799,7 +1799,7 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
|
||||
|> then(
|
||||
context.engine.contacts.searchRemotePeers(query: query, scope: .channels)
|
||||
|> map { ($0.0, $0.1, false) }
|
||||
|> delay(0.2, queue: Queue.concurrentDefaultQueue())
|
||||
|> delay(0.4, queue: Queue.concurrentDefaultQueue())
|
||||
)
|
||||
)
|
||||
} else {
|
||||
@@ -3183,19 +3183,19 @@ final class ChatListSearchListPaneNode: ASDisplayNode, ChatListSearchPaneNode {
|
||||
}
|
||||
}
|
||||
|
||||
let transition = chatListSearchContainerPreparedRecentTransition(from: previousRecentItems?.entries ?? [], to: recentItems.entries, forceUpdateAll: forceUpdateAll, context: context, presentationData: presentationData, filter: peersFilter, key: key, peerSelected: { peer, threadId in
|
||||
let transition = chatListSearchContainerPreparedRecentTransition(from: previousRecentItems?.entries ?? [], to: recentItems.entries, forceUpdateAll: forceUpdateAll, context: context, presentationData: presentationData, filter: peersFilter, key: key, peerSelected: { peer, threadId, isRecommended in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
|
||||
if case .channels = key {
|
||||
if let navigationController = self.navigationController {
|
||||
var customChatNavigationStack: [EnginePeer.Id] = []
|
||||
if let entries = previousRecentItemsValue.with({ $0 })?.entries {
|
||||
for entry in entries {
|
||||
if case let .peer(_, peer, _, _, _, _, _, _, _, _, _) = entry {
|
||||
customChatNavigationStack.append(peer.peer.peerId)
|
||||
}
|
||||
var customChatNavigationStack: [EnginePeer.Id]?
|
||||
if isRecommended {
|
||||
if let recommendedChannelOrder = previousRecentItemsValue.with({ $0 })?.recommendedChannelOrder {
|
||||
var customChatNavigationStackValue: [EnginePeer.Id] = []
|
||||
customChatNavigationStackValue.append(contentsOf: recommendedChannelOrder)
|
||||
customChatNavigationStack = customChatNavigationStackValue
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ public struct ContactsPeerItemEditing: Equatable {
|
||||
public enum ContactsPeerItemPeerMode: Equatable {
|
||||
case generalSearch(isSavedMessages: Bool)
|
||||
case peer
|
||||
case memberList
|
||||
}
|
||||
|
||||
public enum ContactsPeerItemBadgeType {
|
||||
@@ -174,7 +175,7 @@ public class ContactsPeerItem: ItemListItem, ListViewItemWithHeader {
|
||||
let options: [ItemListPeerItemRevealOption]
|
||||
let additionalActions: [ContactsPeerItemAction]
|
||||
let actionIcon: ContactsPeerItemActionIcon
|
||||
let action: (ContactsPeerItemPeer) -> Void
|
||||
let action: ((ContactsPeerItemPeer) -> Void)?
|
||||
let disabledAction: ((ContactsPeerItemPeer) -> Void)?
|
||||
let setPeerIdWithRevealedOptions: ((EnginePeer.Id?, EnginePeer.Id?) -> Void)?
|
||||
let deletePeer: ((EnginePeer.Id) -> Void)?
|
||||
@@ -214,7 +215,7 @@ public class ContactsPeerItem: ItemListItem, ListViewItemWithHeader {
|
||||
actionIcon: ContactsPeerItemActionIcon = .none,
|
||||
index: SortIndex?,
|
||||
header: ListViewItemHeader?,
|
||||
action: @escaping (ContactsPeerItemPeer) -> Void,
|
||||
action: ((ContactsPeerItemPeer) -> Void)?,
|
||||
disabledAction: ((ContactsPeerItemPeer) -> Void)? = nil,
|
||||
setPeerIdWithRevealedOptions: ((EnginePeer.Id?, EnginePeer.Id?) -> Void)? = nil,
|
||||
deletePeer: ((EnginePeer.Id) -> Void)? = nil,
|
||||
@@ -250,7 +251,7 @@ public class ContactsPeerItem: ItemListItem, ListViewItemWithHeader {
|
||||
self.deletePeer = deletePeer
|
||||
self.header = header
|
||||
self.itemHighlighting = itemHighlighting
|
||||
self.selectable = enabled || disabledAction != nil
|
||||
self.selectable = (enabled && action != nil) || disabledAction != nil
|
||||
self.contextAction = contextAction
|
||||
self.arrowAction = arrowAction
|
||||
self.animationCache = animationCache
|
||||
@@ -349,7 +350,7 @@ public class ContactsPeerItem: ItemListItem, ListViewItemWithHeader {
|
||||
|
||||
public func selected(listView: ListView) {
|
||||
if self.enabled {
|
||||
self.action(self.peer)
|
||||
self.action?(self.peer)
|
||||
} else {
|
||||
listView.clearHighlightAnimated(true)
|
||||
self.disabledAction?(self.peer)
|
||||
@@ -748,7 +749,7 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode {
|
||||
var verifiedIcon: EmojiStatusComponent.Content?
|
||||
switch item.peer {
|
||||
case let .peer(peer, _):
|
||||
if let peer = peer, peer.id != item.context.account.peerId {
|
||||
if let peer = peer, (peer.id != item.context.account.peerId || item.peerMode == .memberList) {
|
||||
if peer.isScam {
|
||||
credibilityIcon = .text(color: item.presentationData.theme.chat.message.incoming.scamColor, string: item.presentationData.strings.Message_ScamAccount.uppercased())
|
||||
} else if peer.isFake {
|
||||
|
||||
@@ -171,9 +171,16 @@ func _internal_recommendedChannels(account: Account, peerId: EnginePeer.Id?) ->
|
||||
let key = PostboxViewKey.cachedItem(entryId(peerId: peerId))
|
||||
return account.postbox.combinedView(keys: [key])
|
||||
|> mapToSignal { views -> Signal<RecommendedChannels?, NoError> in
|
||||
guard let cachedChannels = (views.views[key] as? CachedItemView)?.value?.get(CachedRecommendedChannels.self), !cachedChannels.peerIds.isEmpty else {
|
||||
guard let cachedChannels = (views.views[key] as? CachedItemView)?.value?.get(CachedRecommendedChannels.self) else {
|
||||
return .single(nil)
|
||||
}
|
||||
if cachedChannels.peerIds.isEmpty {
|
||||
if peerId != nil {
|
||||
return .single(nil)
|
||||
} else {
|
||||
return .single(RecommendedChannels(channels: [], count: 0, isHidden: false))
|
||||
}
|
||||
}
|
||||
return account.postbox.multiplePeersView(cachedChannels.peerIds)
|
||||
|> mapToSignal { view in
|
||||
return account.postbox.transaction { transaction -> RecommendedChannels? in
|
||||
|
||||
Reference in New Issue
Block a user