mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-08 19:10:53 +00:00
Various improvements
This commit is contained in:
parent
3ce47cc05a
commit
bb8faf1102
@ -1358,6 +1358,18 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
let contextController = ContextController(presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: chatListController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController)), items: chatContextMenuItems(context: strongSelf.context, peerId: peer.peerId, promoInfo: promoInfo, source: .chatList(filter: strongSelf.chatListDisplayNode.mainContainerNode.currentItemNode.chatListFilter), chatListController: strongSelf, joined: joined) |> map { ContextController.Items(content: .list($0)) }, gesture: gesture)
|
||||
strongSelf.presentInGlobalOverlay(contextController)
|
||||
}
|
||||
} else if let peer = peer.peer, peer.id == strongSelf.context.account.peerId, peerData.displayAsTopicList {
|
||||
if let peerInfoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, updatedPresentationData: nil, peer: peer._asPeer(), mode: .generic, avatarInitiallyExpanded: false, fromChat: false, requestsContext: nil) {
|
||||
let source: ContextContentSource
|
||||
if let location = location {
|
||||
source = .location(ChatListContextLocationContentSource(controller: strongSelf, location: location))
|
||||
} else {
|
||||
source = .controller(ContextControllerContentSourceImpl(controller: peerInfoController, sourceNode: node, navigationController: strongSelf.navigationController as? NavigationController))
|
||||
}
|
||||
|
||||
let contextController = ContextController(presentationData: strongSelf.presentationData, source: source, items: chatContextMenuItems(context: strongSelf.context, peerId: peer.id, promoInfo: promoInfo, source: .chatList(filter: strongSelf.chatListDisplayNode.mainContainerNode.currentItemNode.chatListFilter), chatListController: strongSelf, joined: joined) |> map { ContextController.Items(content: .list($0)) }, gesture: gesture)
|
||||
strongSelf.presentInGlobalOverlay(contextController)
|
||||
}
|
||||
} else {
|
||||
let source: ContextContentSource
|
||||
if let location = location {
|
||||
|
@ -1182,13 +1182,29 @@ public final class ChatListNode: ListView {
|
||||
|
||||
private let viewProcessingQueue = Queue()
|
||||
private var chatListView: ChatListNodeView?
|
||||
var entriesCount: Int {
|
||||
public var entriesCount: Int {
|
||||
if let chatListView = self.chatListView {
|
||||
return chatListView.filteredEntries.count
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
public var entryPeerIds: [EnginePeer.Id] {
|
||||
if let chatListView = self.chatListView {
|
||||
return chatListView.filteredEntries.compactMap { item -> EnginePeer.Id? in
|
||||
switch item.stableId {
|
||||
case .Header, .Hole:
|
||||
return nil
|
||||
case let .PeerId(value):
|
||||
return PeerId(value)
|
||||
case .ThreadId, .GroupId, .ContactId, .ArchiveIntro, .EmptyIntro, .SectionHeader, .Notice, .additionalCategory:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return []
|
||||
}
|
||||
}
|
||||
private var interaction: ChatListNodeInteraction?
|
||||
|
||||
private var dequeuedInitialTransitionOnLayout = false
|
||||
|
@ -1503,7 +1503,7 @@ open class TextNode: ASDisplayNode {
|
||||
if let titleLine = segment.titleLine {
|
||||
titleLine.frame = CGRect(origin: CGPoint(x: titleLine.frame.origin.x, y: -insets.bottom + size.height + titleLine.frame.size.height), size: titleLine.frame.size)
|
||||
titleLine.frame.size.width += max(0.0, segment.additionalWidth - 2.0)
|
||||
size.height += titleLine.frame.height
|
||||
size.height += titleLine.frame.height + titleLine.frame.height * lineSpacingFactor
|
||||
blockWidth = max(blockWidth, titleLine.frame.origin.x + titleLine.frame.width)
|
||||
|
||||
lines.append(titleLine)
|
||||
@ -1512,8 +1512,7 @@ open class TextNode: ASDisplayNode {
|
||||
for line in segment.lines {
|
||||
line.frame = CGRect(origin: CGPoint(x: line.frame.origin.x, y: -insets.bottom + size.height + line.frame.size.height), size: line.frame.size)
|
||||
line.frame.size.width += max(0.0, segment.additionalWidth - 2.0)
|
||||
//line.frame.size.width = max(blockWidth, line.frame.size.width)
|
||||
size.height += line.frame.height
|
||||
size.height += line.frame.height + line.frame.height * lineSpacingFactor
|
||||
blockWidth = max(blockWidth, line.frame.origin.x + line.frame.width)
|
||||
|
||||
if let range = line.range {
|
||||
|
@ -319,12 +319,20 @@ public final class PeerInfoChatListPaneNode: ASDisplayNode, PeerInfoPaneNode, UI
|
||||
return true
|
||||
})
|
||||
|
||||
self.parentController?.present(UndoOverlayController(presentationData: self.context.sharedContext.currentPresentationData.with { $0 }, content: .removedChat(title: self.presentationData.strings.SavedMessages_SubChatDeleted, text: nil), elevatedLayout: false, animateInAsReplacement: true, action: { [weak self] value in
|
||||
guard let self else {
|
||||
return false
|
||||
}
|
||||
if self.chatListNode.entryPeerIds.count == 0 || self.chatListNode.entryPeerIds == [peer.id] {
|
||||
let _ = context.engine.messages.clearHistoryInteractively(peerId: self.context.account.peerId, threadId: peer.id.toInt64(), type: .forLocalPeer).startStandalone(completed: {
|
||||
})
|
||||
context.engine.peers.updateSavedMessagesViewAsTopics(value: false)
|
||||
|
||||
self.parentController?.dismiss()
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
let context = self.context
|
||||
let undoController = UndoOverlayController(presentationData: self.context.sharedContext.currentPresentationData.with { $0 }, content: .removedChat(title: self.presentationData.strings.SavedMessages_SubChatDeleted, text: nil), elevatedLayout: false, animateInAsReplacement: true, action: { [weak self] value in
|
||||
if value == .commit {
|
||||
let _ = self.context.engine.messages.clearHistoryInteractively(peerId: self.context.account.peerId, threadId: peer.id.toInt64(), type: .forLocalPeer).startStandalone(completed: { [weak self] in
|
||||
let _ = context.engine.messages.clearHistoryInteractively(peerId: context.account.peerId, threadId: peer.id.toInt64(), type: .forLocalPeer).startStandalone(completed: {
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
@ -336,15 +344,18 @@ public final class PeerInfoChatListPaneNode: ASDisplayNode, PeerInfoPaneNode, UI
|
||||
})
|
||||
return true
|
||||
} else if value == .undo {
|
||||
self.chatListNode.updateState({ state in
|
||||
var state = state
|
||||
state.pendingRemovalItemIds.remove(ChatListNodeState.ItemId(peerId: peer.id, threadId: nil))
|
||||
return state
|
||||
})
|
||||
if let self {
|
||||
self.chatListNode.updateState({ state in
|
||||
var state = state
|
||||
state.pendingRemovalItemIds.remove(ChatListNodeState.ItemId(peerId: peer.id, threadId: nil))
|
||||
return state
|
||||
})
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}), in: .current)
|
||||
})
|
||||
self.parentController?.present(undoController, in: .window(.root))
|
||||
}))
|
||||
|
||||
actionSheet.setItemGroups([ActionSheetItemGroup(items: items),
|
||||
|
@ -7171,17 +7171,30 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
var closeOnEmpty = false
|
||||
if case .pinnedMessages = self.presentationInterfaceState.subject {
|
||||
closeOnEmpty = true
|
||||
} else if case let .replyThread(replyThreadMessage) = self.chatLocation, replyThreadMessage.peerId == self.context.account.peerId {
|
||||
closeOnEmpty = false
|
||||
} else if self.chatLocation.peerId == self.context.account.peerId {
|
||||
if let data = self.context.currentAppConfiguration.with({ $0 }).data, let _ = data["ios_killswitch_disable_close_empty_saved"] {
|
||||
} else {
|
||||
closeOnEmpty = true
|
||||
}
|
||||
}
|
||||
|
||||
if closeOnEmpty {
|
||||
self.chatDisplayNode.historyNode.addSetLoadStateUpdated({ [weak self] state, _ in
|
||||
guard let strongSelf = self else {
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
if case .empty = state {
|
||||
strongSelf.dismiss()
|
||||
if self.chatLocation.peerId == self.context.account.peerId {
|
||||
if self.chatDisplayNode.historyNode.tag != nil {
|
||||
self.updateChatPresentationInterfaceState(animated: true, interactive: false, { state in
|
||||
return state.updatedSearch(nil).updatedHistoryFilter(nil)
|
||||
})
|
||||
} else if case .replyThread = self.chatLocation {
|
||||
self.dismiss()
|
||||
}
|
||||
} else {
|
||||
self.dismiss()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user