Rewritten chat grouping

This commit is contained in:
Peter 2019-04-25 21:18:38 +04:00
parent 06ad876b5f
commit fdfcc2d7fa
15 changed files with 78 additions and 65 deletions

View File

@ -229,13 +229,13 @@ public final class AvatarNode: ASDisplayNode {
let updatedState: AvatarNodeState = .peerAvatar(peer?.id ?? PeerId(namespace: 0, id: 0), peer?.displayLetters ?? [], representation)
if updatedState != self.state || theme !== self.theme {
self.state = updatedState
self.theme = theme
let parameters: AvatarNodeParameters
self.displaySuspended = true
self.contents = nil
if let peer = peer, let signal = peerAvatarImage(account: account, peer: peer, authorOfMessage: authorOfMessage, representation: representation, emptyColor: emptyColor, synchronousLoad: synchronousLoad) {
self.contents = nil
self.displaySuspended = true
self.imageReady.set(self.imageNode.ready)
self.imageNode.setSignal(signal)

View File

@ -59,7 +59,7 @@ public class ChatListController: TelegramController, KeyShortcutResponder, UIVie
private let controlsHistoryPreload: Bool
private let hideNetworkActivityStatus: Bool
public let groupId: PeerGroupId?
public let groupId: PeerGroupId
let openMessageFromSearchDisposable: MetaDisposable = MetaDisposable()
@ -93,7 +93,7 @@ public class ChatListController: TelegramController, KeyShortcutResponder, UIVie
private var searchContentNode: NavigationBarSearchContentNode?
public init(context: AccountContext, groupId: PeerGroupId?, controlsHistoryPreload: Bool, hideNetworkActivityStatus: Bool = false) {
public init(context: AccountContext, groupId: PeerGroupId, controlsHistoryPreload: Bool, hideNetworkActivityStatus: Bool = false) {
self.context = context
self.controlsHistoryPreload = controlsHistoryPreload
self.hideNetworkActivityStatus = hideNetworkActivityStatus
@ -109,7 +109,7 @@ public class ChatListController: TelegramController, KeyShortcutResponder, UIVie
self.statusBar.statusBarStyle = self.presentationData.theme.rootController.statusBar.style.style
if groupId == nil {
if case .root = groupId {
self.navigationBar?.item = nil
self.titleView.title = NetworkStatusTitle(text: self.presentationData.strings.DialogList_Title, activity: false, hasProxy: false, connectsViaProxy: false, isPasscodeSet: false, isManuallyLocked: false)
@ -202,14 +202,14 @@ public class ChatListController: TelegramController, KeyShortcutResponder, UIVie
self.titleDisposable = combineLatest(queue: .mainQueue(), context.account.networkState, hasProxy, passcode, self.chatListDisplayNode.chatListNode.state).start(next: { [weak self] networkState, proxy, passcode, state in
if let strongSelf = self {
if state.editing {
if strongSelf.groupId == nil {
if case .root = strongSelf.groupId {
strongSelf.navigationItem.rightBarButtonItem = nil
}
let title = !state.selectedPeerIds.isEmpty ? strongSelf.presentationData.strings.ChatList_SelectedChats(Int32(state.selectedPeerIds.count)) : strongSelf.presentationData.strings.DialogList_Title
strongSelf.titleView.title = NetworkStatusTitle(text: title, activity: false, hasProxy: false, connectsViaProxy: false, isPasscodeSet: false, isManuallyLocked: false)
} else {
if strongSelf.groupId == nil {
if case .root = strongSelf.groupId {
let rightBarButtonItem = UIBarButtonItem(image: PresentationResourcesRootController.navigationComposeIcon(strongSelf.presentationData.theme), style: .plain, target: strongSelf, action: #selector(strongSelf.composePressed))
rightBarButtonItem.accessibilityLabel = "Compose"
strongSelf.navigationItem.rightBarButtonItem = rightBarButtonItem
@ -360,7 +360,7 @@ public class ChatListController: TelegramController, KeyShortcutResponder, UIVie
editItem = UIBarButtonItem(title: self.presentationData.strings.Common_Edit, style: .plain, target: self, action: #selector(self.editPressed))
editItem.accessibilityLabel = self.presentationData.strings.Common_Edit
}
if self.groupId == nil {
if case .root = self.groupId {
self.navigationItem.leftBarButtonItem = editItem
let rightBarButtonItem = UIBarButtonItem(image: PresentationResourcesRootController.navigationComposeIcon(self.presentationData.theme), style: .plain, target: self, action: #selector(self.composePressed))
rightBarButtonItem.accessibilityLabel = "Compose"
@ -621,7 +621,7 @@ public class ChatListController: TelegramController, KeyShortcutResponder, UIVie
strongSelf.archiveChat(peerId: peerId)
} else {
strongSelf.chatListDisplayNode.chatListNode.setCurrentRemovingPeerId(peerId)
let _ = updatePeerGroupIdInteractively(postbox: strongSelf.context.account.postbox, peerId: peerId, groupId: group ? Namespaces.PeerGroup.archive : nil).start(completed: {
let _ = updatePeerGroupIdInteractively(postbox: strongSelf.context.account.postbox, peerId: peerId, groupId: group ? Namespaces.PeerGroup.archive : .root).start(completed: {
guard let strongSelf = self else {
return
}
@ -781,7 +781,7 @@ public class ChatListController: TelegramController, KeyShortcutResponder, UIVie
return
}
var toolbar: Toolbar?
if strongSelf.groupId == nil {
if case .root = strongSelf.groupId {
if let (options, _) = peerIdsAndOptions {
let leftAction: ToolbarAction
switch options.read {
@ -972,7 +972,7 @@ public class ChatListController: TelegramController, KeyShortcutResponder, UIVie
@objc func editPressed() {
let editItem = UIBarButtonItem(title: self.presentationData.strings.Common_Done, style: .done, target: self, action: #selector(self.donePressed))
editItem.accessibilityLabel = self.presentationData.strings.Common_Done
if self.groupId == nil {
if case .root = self.groupId {
self.navigationItem.leftBarButtonItem = editItem
} else {
self.navigationItem.rightBarButtonItem = editItem
@ -989,7 +989,7 @@ public class ChatListController: TelegramController, KeyShortcutResponder, UIVie
@objc func donePressed() {
let editItem = UIBarButtonItem(title: self.presentationData.strings.Common_Edit, style: .plain, target: self, action: #selector(self.editPressed))
editItem.accessibilityLabel = self.presentationData.strings.Common_Edit
if self.groupId == nil {
if case .root = self.groupId {
self.navigationItem.leftBarButtonItem = editItem
} else {
self.navigationItem.rightBarButtonItem = editItem
@ -1205,7 +1205,7 @@ public class ChatListController: TelegramController, KeyShortcutResponder, UIVie
override public func toolbarActionSelected(left: Bool) {
let peerIds = self.chatListDisplayNode.chatListNode.currentState.selectedPeerIds
if left {
if self.groupId == nil {
if case .root = self.groupId {
let signal: Signal<Void, NoError>
let context = self.context
if !peerIds.isEmpty {
@ -1215,8 +1215,9 @@ public class ChatListController: TelegramController, KeyShortcutResponder, UIVie
}
}
} else {
let groupId = self.groupId
signal = self.context.account.postbox.transaction { transaction -> Void in
markAllChatsAsReadInteractively(transaction: transaction, viewTracker: context.account.viewTracker)
markAllChatsAsReadInteractively(transaction: transaction, viewTracker: context.account.viewTracker, groupId: groupId)
}
}
let _ = (signal
@ -1227,7 +1228,7 @@ public class ChatListController: TelegramController, KeyShortcutResponder, UIVie
self.chatListDisplayNode.chatListNode.setCurrentRemovingPeerId(peerIds.first!)
let _ = (self.context.account.postbox.transaction { transaction -> Void in
for peerId in peerIds {
updatePeerGroupIdInteractively(transaction: transaction, peerId: peerId, groupId: nil)
updatePeerGroupIdInteractively(transaction: transaction, peerId: peerId, groupId: .root)
}
}
|> deliverOnMainQueue).start(completed: { [weak self] in
@ -1360,7 +1361,7 @@ public class ChatListController: TelegramController, KeyShortcutResponder, UIVie
}
if !shouldCommit {
strongSelf.chatListDisplayNode.chatListNode.setCurrentRemovingPeerId(peerId)
let _ = (updatePeerGroupIdInteractively(postbox: strongSelf.context.account.postbox, peerId: peerId, groupId: nil)
let _ = (updatePeerGroupIdInteractively(postbox: strongSelf.context.account.postbox, peerId: peerId, groupId: .root)
|> deliverOnMainQueue).start(completed: {
guard let strongSelf = self else {
return
@ -1451,7 +1452,7 @@ public class ChatListController: TelegramController, KeyShortcutResponder, UIVie
}
override public func setToolbar(_ toolbar: Toolbar?, transition: ContainedViewLayoutTransition) {
if self.groupId == nil {
if case .root = self.groupId {
super.setToolbar(toolbar, transition: transition)
} else {
self.chatListDisplayNode.toolbar = toolbar

View File

@ -19,7 +19,7 @@ private final class ChatListControllerNodeView: UITracingLayerView, PreviewingHo
final class ChatListControllerNode: ASDisplayNode {
private let context: AccountContext
private let groupId: PeerGroupId?
private let groupId: PeerGroupId
private var presentationData: PresentationData
private var chatListEmptyNode: ChatListEmptyNode?
@ -43,7 +43,7 @@ final class ChatListControllerNode: ASDisplayNode {
var requestAddContact: ((String) -> Void)?
var dismissSelf: (() -> Void)?
init(context: AccountContext, groupId: PeerGroupId?, controlsHistoryPreload: Bool, presentationData: PresentationData, controller: ChatListController) {
init(context: AccountContext, groupId: PeerGroupId, controlsHistoryPreload: Bool, presentationData: PresentationData, controller: ChatListController) {
self.context = context
self.groupId = groupId
self.presentationData = presentationData

View File

@ -8,7 +8,7 @@ import TelegramCore
enum ChatListItemContent {
case peer(message: Message?, peer: RenderedPeer, combinedReadState: CombinedPeerReadState?, notificationSettings: PeerNotificationSettings?, presence: PeerPresence?, summaryInfo: ChatListMessageTagSummaryInfo, embeddedState: PeerChatListEmbeddedInterfaceState?, inputActivities: [(Peer, PeerInputActivity)]?, isAd: Bool, ignoreUnreadBadge: Bool)
case groupReference(groupId: PeerGroupId, peer: RenderedPeer, message: Message?, unreadState: ChatListTotalUnreadState, hiddenByDefault: Bool)
case groupReference(groupId: PeerGroupId, peer: RenderedPeer, message: Message?, unreadState: PeerGroupUnreadCountersCombinedSummary, hiddenByDefault: Bool)
var chatLocation: ChatLocation? {
switch self {
@ -23,7 +23,7 @@ enum ChatListItemContent {
class ChatListItem: ListViewItem {
let presentationData: ChatListPresentationData
let account: Account
let peerGroupId: PeerGroupId?
let peerGroupId: PeerGroupId
let index: ChatListIndex
let content: ChatListItemContent
let editing: Bool
@ -41,7 +41,7 @@ class ChatListItem: ListViewItem {
let header: ListViewItemHeader?
init(presentationData: ChatListPresentationData, account: Account, peerGroupId: PeerGroupId?, index: ChatListIndex, content: ChatListItemContent, editing: Bool, hasActiveRevealControls: Bool, selected: Bool, header: ListViewItemHeader?, enableContextActions: Bool, hiddenOffset: Bool, interaction: ChatListNodeInteraction) {
init(presentationData: ChatListPresentationData, account: Account, peerGroupId: PeerGroupId, index: ChatListIndex, content: ChatListItemContent, editing: Bool, hasActiveRevealControls: Bool, selected: Bool, header: ListViewItemHeader?, enableContextActions: Bool, hiddenOffset: Bool, interaction: ChatListNodeInteraction) {
self.presentationData = presentationData
self.peerGroupId = peerGroupId
self.account = account
@ -182,7 +182,7 @@ private enum RevealOptionKey: Int32 {
private let itemHeight: CGFloat = 76.0
private func revealOptions(strings: PresentationStrings, theme: PresentationTheme, isPinned: Bool?, isMuted: Bool?, groupId: PeerGroupId?, canDelete: Bool, isEditing: Bool) -> [ItemListRevealOption] {
private func revealOptions(strings: PresentationStrings, theme: PresentationTheme, isPinned: Bool?, isMuted: Bool?, groupId: PeerGroupId, canDelete: Bool, isEditing: Bool) -> [ItemListRevealOption] {
var options: [ItemListRevealOption] = []
if !isEditing {
if let isMuted = isMuted {
@ -197,10 +197,10 @@ private func revealOptions(strings: PresentationStrings, theme: PresentationThem
options.append(ItemListRevealOption(key: RevealOptionKey.delete.rawValue, title: strings.Common_Delete, icon: deleteIcon, color: theme.list.itemDisclosureActions.destructive.fillColor, textColor: theme.list.itemDisclosureActions.destructive.foregroundColor))
}
if !isEditing {
if groupId != nil {
options.append(ItemListRevealOption(key: RevealOptionKey.unarchive.rawValue, title: strings.ChatList_UnarchiveAction, icon: unarchiveIcon, color: theme.list.itemDisclosureActions.constructive.fillColor, textColor: theme.list.itemDisclosureActions.constructive.foregroundColor))
} else {
if case .root = groupId {
options.append(ItemListRevealOption(key: RevealOptionKey.archive.rawValue, title: strings.ChatList_ArchiveAction, icon: archiveIcon, color: theme.list.itemDisclosureActions.constructive.fillColor, textColor: theme.list.itemDisclosureActions.constructive.foregroundColor))
} else {
options.append(ItemListRevealOption(key: RevealOptionKey.unarchive.rawValue, title: strings.ChatList_UnarchiveAction, icon: unarchiveIcon, color: theme.list.itemDisclosureActions.constructive.fillColor, textColor: theme.list.itemDisclosureActions.constructive.foregroundColor))
}
}
return options
@ -581,9 +581,8 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
inputActivities = nil
isPeerGroup = true
groupHiddenByDefault = hiddenByDefault
let unmutedCount = unreadState.count(for: .filtered, in: .chats, with: [.regularChatsAndPrivateGroups, .publicGroups, .channels])
let mutedCount = unreadState.count(for: .raw, in: .chats, with: [.regularChatsAndPrivateGroups, .publicGroups, .channels])
unreadCount = (unmutedCount, unmutedCount != 0 || mutedCount != 0, false, max(0, mutedCount - unmutedCount))
let allCount = unreadState.count(countingCategory: .chats, mutedCategory: .all)
unreadCount = (allCount, allCount != 0, true, nil)
peerPresence = nil
isAd = false
}
@ -737,10 +736,14 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
if message.flags.isSending && !message.isSentOrAcknowledged {
statusState = .clock(PresentationResourcesChatList.clockFrameImage(item.presentationData.theme), PresentationResourcesChatList.clockMinImage(item.presentationData.theme))
} else if message.id.peerId != account.peerId {
if let combinedReadState = combinedReadState, combinedReadState.isOutgoingMessageIndexRead(message.index) {
statusState = .read(item.presentationData.theme.chatList.checkmarkColor)
if message.flags.contains(.Failed) {
statusState = .none
} else {
statusState = .delivered(item.presentationData.theme.chatList.checkmarkColor)
if let combinedReadState = combinedReadState, combinedReadState.isOutgoingMessageIndexRead(message.index) {
statusState = .read(item.presentationData.theme.chatList.checkmarkColor)
} else {
statusState = .delivered(item.presentationData.theme.chatList.checkmarkColor)
}
}
}
}
@ -839,10 +842,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
titleIconsWidth += currentVerificationIconImage.size.width
}
var layoutOffset: CGFloat = 0.0
if item.hiddenOffset {
//layoutOffset = -itemHeight
}
let layoutOffset: CGFloat = 0.0
let rawContentRect = CGRect(origin: CGPoint(x: 2.0, y: layoutOffset + 8.0), size: CGSize(width: params.width - leftInset - params.rightInset - 10.0 - 1.0 - editingOffset, height: itemHeight - 12.0 - 9.0))
@ -1057,7 +1057,6 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
let _ = strongSelf.statusNode.transitionToState(statusState, animated: animateContent)
if let _ = currentBadgeBackgroundImage {
let previousBadgeFrame = strongSelf.badgeNode.frame
let badgeFrame = CGRect(x: contentRect.maxX - badgeLayout.width, y: contentRect.maxY - badgeLayout.height - 2.0, width: badgeLayout.width, height: badgeLayout.height)
transition.updateFrame(node: strongSelf.badgeNode, frame: badgeFrame)
@ -1284,10 +1283,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
editingOffset = 0.0
}
var layoutOffset: CGFloat = 0.0
if item.hiddenOffset {
//layoutOffset = -itemHeight
}
let layoutOffset: CGFloat = 0.0
if let reorderControlNode = self.reorderControlNode {
var reorderControlFrame = reorderControlNode.frame

View File

@ -137,7 +137,7 @@ struct ChatListNodeState: Equatable {
}
}
private func mappedInsertEntries(account: Account, nodeInteraction: ChatListNodeInteraction, peerGroupId: PeerGroupId?, mode: ChatListNodeMode, entries: [ChatListNodeViewTransitionInsertEntry]) -> [ListViewInsertItem] {
private func mappedInsertEntries(account: Account, nodeInteraction: ChatListNodeInteraction, peerGroupId: PeerGroupId, mode: ChatListNodeMode, entries: [ChatListNodeViewTransitionInsertEntry]) -> [ListViewInsertItem] {
return entries.map { entry -> ListViewInsertItem in
switch entry.entry {
case let .PeerEntry(index, presentationData, message, combinedReadState, notificationSettings, embeddedState, peer, presence, summaryInfo, editing, hasActiveRevealControls, selected, inputActivities, isAd):
@ -216,7 +216,7 @@ private func mappedInsertEntries(account: Account, nodeInteraction: ChatListNode
}
}
private func mappedUpdateEntries(account: Account, nodeInteraction: ChatListNodeInteraction, peerGroupId: PeerGroupId?, mode: ChatListNodeMode, entries: [ChatListNodeViewTransitionUpdateEntry]) -> [ListViewUpdateItem] {
private func mappedUpdateEntries(account: Account, nodeInteraction: ChatListNodeInteraction, peerGroupId: PeerGroupId, mode: ChatListNodeMode, entries: [ChatListNodeViewTransitionUpdateEntry]) -> [ListViewUpdateItem] {
return entries.map { entry -> ListViewUpdateItem in
switch entry.entry {
case let .PeerEntry(index, presentationData, message, combinedReadState, notificationSettings, embeddedState, peer, presence, summaryInfo, editing, hasActiveRevealControls, selected, inputActivities, isAd):
@ -253,7 +253,7 @@ private func mappedUpdateEntries(account: Account, nodeInteraction: ChatListNode
}
}
private func mappedChatListNodeViewListTransition(account: Account, nodeInteraction: ChatListNodeInteraction, peerGroupId: PeerGroupId?, mode: ChatListNodeMode, transition: ChatListNodeViewTransition) -> ChatListNodeListViewTransition {
private func mappedChatListNodeViewListTransition(account: Account, nodeInteraction: ChatListNodeInteraction, peerGroupId: PeerGroupId, mode: ChatListNodeMode, transition: ChatListNodeViewTransition) -> ChatListNodeListViewTransition {
return ChatListNodeListViewTransition(chatListView: transition.chatListView, deleteItems: transition.deleteItems, insertItems: mappedInsertEntries(account: account, nodeInteraction: nodeInteraction, peerGroupId: peerGroupId, mode: mode, entries: transition.insertEntries), updateItems: mappedUpdateEntries(account: account, nodeInteraction: nodeInteraction, peerGroupId: peerGroupId, mode: mode, entries: transition.updateEntries), options: transition.options, scrollToItem: transition.scrollToItem, stationaryItemRange: transition.stationaryItemRange)
}
@ -297,6 +297,7 @@ enum ChatListNodeEmtpyState: Equatable {
final class ChatListNode: ListView {
private let controlsHistoryPreload: Bool
private let context: AccountContext
private let groupId: PeerGroupId
private let mode: ChatListNodeMode
private let _ready = ValuePromise<Bool>()
@ -369,8 +370,9 @@ final class ChatListNode: ListView {
private var hapticFeedback: HapticFeedback?
init(context: AccountContext, groupId: PeerGroupId?, controlsHistoryPreload: Bool, mode: ChatListNodeMode, theme: PresentationTheme, strings: PresentationStrings, dateTimeFormat: PresentationDateTimeFormat, nameSortOrder: PresentationPersonNameOrder, nameDisplayOrder: PresentationPersonNameOrder, disableAnimations: Bool) {
init(context: AccountContext, groupId: PeerGroupId, controlsHistoryPreload: Bool, mode: ChatListNodeMode, theme: PresentationTheme, strings: PresentationStrings, dateTimeFormat: PresentationDateTimeFormat, nameSortOrder: PresentationPersonNameOrder, nameDisplayOrder: PresentationPersonNameOrder, disableAnimations: Bool) {
self.context = context
self.groupId = groupId
self.controlsHistoryPreload = controlsHistoryPreload
self.mode = mode
@ -999,7 +1001,7 @@ final class ChatListNode: ListView {
case let .known(value):
atTop = value <= 0.0
if startedScrollingAtUpperBound && strongSelf.isTracking {
revealHiddenItems = value <= -76.0
revealHiddenItems = value <= -60.0
}
}
strongSelf.scrolledAtTopValue = atTop
@ -1205,6 +1207,7 @@ final class ChatListNode: ListView {
}
private func relativeUnreadChatListIndex(position: ChatListRelativePosition) -> Signal<ChatListIndex?, NoError> {
let groupId = self.groupId
let postbox = self.context.account.postbox
return self.context.sharedContext.accountManager.transaction { transaction -> Signal<ChatListIndex?, NoError> in
var filter = true
@ -1217,7 +1220,7 @@ final class ChatListNode: ListView {
}
}
return postbox.transaction { transaction -> ChatListIndex? in
return transaction.getRelativeUnreadChatListIndex(filtered: filter, position: position)
return transaction.getRelativeUnreadChatListIndex(filtered: filter, position: position, groupId: groupId)
}
}
|> switchToLatest
@ -1334,7 +1337,7 @@ final class ChatListNode: ListView {
guard index < 10 else {
return
}
let _ = (chatListViewForLocation(groupId: nil, location: .initial(count: 10), account: self.context.account)
let _ = (chatListViewForLocation(groupId: self.groupId, location: .initial(count: 10), account: self.context.account)
|> take(1)
|> deliverOnMainQueue).start(next: { update in
let entries = update.view.entries

View File

@ -45,7 +45,7 @@ enum ChatListNodeEntryId: Hashable {
enum ChatListNodeEntry: Comparable, Identifiable {
case PeerEntry(index: ChatListIndex, presentationData: ChatListPresentationData, message: Message?, readState: CombinedPeerReadState?, notificationSettings: PeerNotificationSettings?, embeddedInterfaceState: PeerChatListEmbeddedInterfaceState?, peer: RenderedPeer, presence: PeerPresence?, summaryInfo: ChatListMessageTagSummaryInfo, editing: Bool, hasActiveRevealControls: Bool, selected: Bool, inputActivities: [(Peer, PeerInputActivity)]?, isAd: Bool)
case HoleEntry(ChatListHole, theme: PresentationTheme)
case GroupReferenceEntry(index: ChatListIndex, presentationData: ChatListPresentationData, groupId: PeerGroupId, peer: RenderedPeer, message: Message?, editing: Bool, unreadState: ChatListTotalUnreadState, revealed: Bool, hiddenByDefault: Bool)
case GroupReferenceEntry(index: ChatListIndex, presentationData: ChatListPresentationData, groupId: PeerGroupId, peer: RenderedPeer, message: Message?, editing: Bool, unreadState: PeerGroupUnreadCountersCombinedSummary, revealed: Bool, hiddenByDefault: Bool)
var index: ChatListIndex {
switch self {

View File

@ -30,17 +30,19 @@ struct ChatListNodeViewUpdate {
let scrollPosition: ChatListNodeViewScrollPosition?
}
func chatListViewForLocation(groupId: PeerGroupId?, location: ChatListNodeLocation, account: Account) -> Signal<ChatListNodeViewUpdate, NoError> {
func chatListViewForLocation(groupId: PeerGroupId, location: ChatListNodeLocation, account: Account) -> Signal<ChatListNodeViewUpdate, NoError> {
switch location {
case let .initial(count):
let signal: Signal<(ChatListView, ViewUpdateType), NoError>
signal = account.viewTracker.tailChatListView(groupId: groupId, count: count)
return signal |> map { view, updateType -> ChatListNodeViewUpdate in
return signal
|> map { view, updateType -> ChatListNodeViewUpdate in
return ChatListNodeViewUpdate(view: view, type: updateType, scrollPosition: nil)
}
case let .navigation(index):
var first = true
return account.viewTracker.aroundChatListView(groupId: groupId, index: index, count: 80) |> map { view, updateType -> ChatListNodeViewUpdate in
return account.viewTracker.aroundChatListView(groupId: groupId, index: index, count: 80)
|> map { view, updateType -> ChatListNodeViewUpdate in
let genericType: ViewUpdateType
if first {
first = false
@ -54,7 +56,8 @@ func chatListViewForLocation(groupId: PeerGroupId?, location: ChatListNodeLocati
let directionHint: ListViewScrollToItemDirectionHint = sourceIndex > index ? .Down : .Up
let chatScrollPosition: ChatListNodeViewScrollPosition = .index(index: index, position: scrollPosition, directionHint: directionHint, animated: animated)
var first = true
return account.viewTracker.aroundChatListView(groupId: groupId, index: index, count: 80) |> map { view, updateType -> ChatListNodeViewUpdate in
return account.viewTracker.aroundChatListView(groupId: groupId, index: index, count: 80)
|> map { view, updateType -> ChatListNodeViewUpdate in
let genericType: ViewUpdateType
let scrollPosition: ChatListNodeViewScrollPosition? = first ? chatScrollPosition : nil
if first {

View File

@ -446,7 +446,7 @@ enum ChatListSearchEntry: Comparable, Identifiable {
interaction.peerSelected(peer.peer)
})
case let .message(message, readState, presentationData):
return ChatListItem(presentationData: presentationData, account: context.account, peerGroupId: nil, index: ChatListIndex(pinningIndex: nil, messageIndex: message.index), content: .peer(message: message, peer: RenderedPeer(message: message), combinedReadState: readState, notificationSettings: nil, presence: nil, summaryInfo: ChatListMessageTagSummaryInfo(), embeddedState: nil, inputActivities: nil, isAd: false, ignoreUnreadBadge: true), editing: false, hasActiveRevealControls: false, selected: false, header: enableHeaders ? ChatListSearchItemHeader(type: .messages, theme: presentationData.theme, strings: presentationData.strings, actionTitle: nil, action: nil) : nil, enableContextActions: false, hiddenOffset: false, interaction: interaction)
return ChatListItem(presentationData: presentationData, account: context.account, peerGroupId: .root, index: ChatListIndex(pinningIndex: nil, messageIndex: message.index), content: .peer(message: message, peer: RenderedPeer(message: message), combinedReadState: readState, notificationSettings: nil, presence: nil, summaryInfo: ChatListMessageTagSummaryInfo(), embeddedState: nil, inputActivities: nil, isAd: false, ignoreUnreadBadge: true), editing: false, hasActiveRevealControls: false, selected: false, header: enableHeaders ? ChatListSearchItemHeader(type: .messages, theme: presentationData.theme, strings: presentationData.strings, actionTitle: nil, action: nil) : nil, enableContextActions: false, hiddenOffset: false, interaction: interaction)
case let .addContact(phoneNumber, theme, strings):
return ContactsAddItem(theme: theme, strings: strings, phoneNumber: phoneNumber, header: ChatListSearchItemHeader(type: .phoneNumber, theme: theme, strings: strings, actionTitle: nil, action: nil), action: {
interaction.addContact(phoneNumber)
@ -568,7 +568,7 @@ final class ChatListSearchContainerNode: SearchDisplayControllerContentNode {
private let filter: ChatListNodePeersFilter
init(context: AccountContext, filter: ChatListNodePeersFilter, groupId: PeerGroupId?, openPeer: @escaping (Peer, Bool) -> Void, openRecentPeerOptions: @escaping (Peer) -> Void, openMessage: @escaping (Peer, MessageId) -> Void, addContact: ((String) -> Void)?) {
init(context: AccountContext, filter: ChatListNodePeersFilter, groupId: PeerGroupId, openPeer: @escaping (Peer, Bool) -> Void, openRecentPeerOptions: @escaping (Peer) -> Void, openMessage: @escaping (Peer, MessageId) -> Void, addContact: ((String) -> Void)?) {
self.context = context
self.filter = filter
self.dimNode = ASDisplayNode()
@ -641,7 +641,7 @@ final class ChatListSearchContainerNode: SearchDisplayControllerContentNode {
let accountPeer = context.account.postbox.loadedPeerWithId(context.account.peerId)
|> take(1)
let foundLocalPeers = context.account.postbox.searchPeers(query: query.lowercased(), groupId: nil)
let foundLocalPeers = context.account.postbox.searchPeers(query: query.lowercased())
|> mapToSignal { local -> Signal<([PeerView], [RenderedPeer]), NoError> in
return combineLatest(local.map { context.account.postbox.peerView(id: $0.peerId) }) |> map { views in
return (views, local)

View File

@ -934,7 +934,7 @@ final class ContactListNode: ASDisplayNode {
|> mapToSignal { query in
let foundLocalContacts: Signal<([Peer], [PeerId : PeerPresence]), NoError>
if searchChatList {
let foundChatListPeers = context.account.postbox.searchPeers(query: query.lowercased(), groupId: nil)
let foundChatListPeers = context.account.postbox.searchPeers(query: query.lowercased())
foundLocalContacts = foundChatListPeers
|> mapToSignal { peers -> Signal<([Peer], [PeerId : PeerPresence]), NoError> in
var resultPeers: [Peer] = []

View File

@ -367,7 +367,12 @@ final class ItemListRevealOptionsNode: ASDisplayNode {
let basicNodeWidth = floor((size.width - abs(self.sideInset)) / CGFloat(self.optionNodes.count))
let lastNodeWidth = size.width - basicNodeWidth * CGFloat(self.optionNodes.count - 1)
let revealFactor = self.revealOffset / size.width
let boundaryRevealFactor: CGFloat = 1.0 + 16.0 / size.width
let boundaryRevealFactor: CGFloat
if self.optionNodes.count > 2 {
boundaryRevealFactor = 1.0 + 16.0 / size.width
} else {
boundaryRevealFactor = 1.0 + basicNodeWidth / size.width
}
let startingOffset: CGFloat
if self.isLeft {
startingOffset = size.width + max(0.0, abs(revealFactor) - 1.0) * size.width

View File

@ -74,7 +74,7 @@ final class PeerSelectionControllerNode: ASDisplayNode {
}
self.chatListNode = ChatListNode(context: context, groupId: nil, controlsHistoryPreload: false, mode: .peers(filter: filter), theme: presentationData.theme, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameSortOrder: presentationData.nameSortOrder, nameDisplayOrder: presentationData.nameDisplayOrder, disableAnimations: presentationData.disableAnimations)
self.chatListNode = ChatListNode(context: context, groupId: .root, controlsHistoryPreload: false, mode: .peers(filter: filter), theme: presentationData.theme, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, nameSortOrder: presentationData.nameSortOrder, nameDisplayOrder: presentationData.nameDisplayOrder, disableAnimations: presentationData.disableAnimations)
super.init()
@ -216,7 +216,7 @@ final class PeerSelectionControllerNode: ASDisplayNode {
}
if self.chatListNode.supernode != nil {
self.searchDisplayController = SearchDisplayController(presentationData: self.presentationData, contentNode: ChatListSearchContainerNode(context: self.context, filter: self.filter, groupId: nil, openPeer: { [weak self] peer, _ in
self.searchDisplayController = SearchDisplayController(presentationData: self.presentationData, contentNode: ChatListSearchContainerNode(context: self.context, filter: self.filter, groupId: .root, openPeer: { [weak self] peer, _ in
if let requestOpenPeerFromSearch = self?.requestOpenPeerFromSearch {
requestOpenPeerFromSearch(peer)
}

View File

@ -1363,7 +1363,7 @@ public func settingsController(context: AccountContext, accountManager: AccountM
})
if let selectedAccount = selectedAccount, let sharedContext = sharedContext {
let accountContext = AccountContext(sharedContext: sharedContext, account: selectedAccount, limitsConfiguration: LimitsConfiguration.defaultValue)
let chatListController = ChatListController(context: accountContext, groupId: nil, controlsHistoryPreload: false, hideNetworkActivityStatus: true)
let chatListController = ChatListController(context: accountContext, groupId: .root, controlsHistoryPreload: false, hideNetworkActivityStatus: true)
return chatListController
}

View File

@ -655,7 +655,12 @@ public final class ShareController: ViewController {
self.currentAccount = account
self.acountActiveDisposable.set(self.sharedContext.setAccountUserInterfaceInUse(account.id))
self.peers.set(combineLatest(self.currentAccount.postbox.loadedPeerWithId(self.currentAccount.peerId) |> take(1), self.currentAccount.viewTracker.tailChatListView(groupId: nil, count: 150) |> take(1))
self.peers.set(combineLatest(
self.currentAccount.postbox.loadedPeerWithId(self.currentAccount.peerId)
|> take(1),
self.currentAccount.viewTracker.tailChatListView(groupId: .root, count: 150)
|> take(1)
)
|> map { accountPeer, view -> ([(RenderedPeer, PeerPresence?)], Peer) in
var peers: [(RenderedPeer, PeerPresence?)] = []
for entry in view.0.entries.reversed() {

View File

@ -241,7 +241,7 @@ final class ShareSearchContainerNode: ASDisplayNode, ShareContentContainerNode {
|> mapToSignal { query -> Signal<[ShareSearchPeerEntry]?, NoError> in
if !query.isEmpty {
let accountPeer = account.postbox.loadedPeerWithId(account.peerId) |> take(1)
let foundLocalPeers = account.postbox.searchPeers(query: query.lowercased(), groupId: nil)
let foundLocalPeers = account.postbox.searchPeers(query: query.lowercased())
let foundRemotePeers: Signal<([FoundPeer], [FoundPeer]), NoError> = .single(([], []))
|> then(
searchPeers(account: account, query: query)

View File

@ -51,7 +51,7 @@ public final class TelegramRootController: NavigationController {
public func addRootControllers(showCallsTab: Bool) {
let tabBarController = TabBarController(navigationBarPresentationData: NavigationBarPresentationData(presentationData: self.presentationData), theme: TabBarControllerTheme(rootControllerTheme: self.presentationData.theme))
let chatListController = ChatListController(context: self.context, groupId: nil, controlsHistoryPreload: true)
let chatListController = ChatListController(context: self.context, groupId: .root, controlsHistoryPreload: true)
chatListController.tabBarItem.badgeValue = self.context.sharedContext.switchingData.chatListBadge
let callListController = CallListController(context: self.context, mode: .tab)