|
@@ -98,6 +98,11 @@ class ChatListController: UIViewController {
|
|
|
coordinator?.showNewChatController()
|
|
|
}
|
|
|
|
|
|
+ private func getNumberOfArchivedChats() -> Int {
|
|
|
+ let chatList = dcContext.getChatlist(flags: DC_GCL_ARCHIVED_ONLY, queryString: nil, queryId: 0)
|
|
|
+ return chatList.length
|
|
|
+ }
|
|
|
+
|
|
|
private func getChatList() {
|
|
|
var gclFlags: Int32 = 0
|
|
|
if showArchive {
|
|
@@ -123,6 +128,11 @@ extension ChatListController: UITableViewDataSource, UITableViewDelegate {
|
|
|
fatalError("chatList was nil in data source")
|
|
|
}
|
|
|
|
|
|
+ let chatId = chatList.getChatId(index: row)
|
|
|
+ if chatId == DC_CHAT_ID_ARCHIVED_LINK {
|
|
|
+ return getArchiveCell(tableView)
|
|
|
+ }
|
|
|
+
|
|
|
let cell: ContactCell
|
|
|
if let c = tableView.dequeueReusableCell(withIdentifier: "ChatCell") as? ContactCell {
|
|
|
cell = c
|
|
@@ -130,7 +140,6 @@ extension ChatListController: UITableViewDataSource, UITableViewDelegate {
|
|
|
cell = ContactCell(style: .default, reuseIdentifier: "ChatCell")
|
|
|
}
|
|
|
|
|
|
- let chatId = chatList.getChatId(index: row)
|
|
|
let chat = DcChat(id: chatId)
|
|
|
let summary = chatList.getSummary(index: row)
|
|
|
|
|
@@ -200,6 +209,22 @@ extension ChatListController: UITableViewDataSource, UITableViewDelegate {
|
|
|
return [archive, delete]
|
|
|
}
|
|
|
|
|
|
+ func getArchiveCell(_ tableView: UITableView) -> UITableViewCell {
|
|
|
+ let archiveCell: UITableViewCell
|
|
|
+ if let cell = tableView.dequeueReusableCell(withIdentifier: "ArchiveCell") {
|
|
|
+ archiveCell = cell
|
|
|
+ } else {
|
|
|
+ archiveCell = UITableViewCell(style: .default, reuseIdentifier: "ArchiveCell")
|
|
|
+ }
|
|
|
+ archiveCell.textLabel?.textAlignment = .center
|
|
|
+ var title = String.localized("chat_archived_chats_title")
|
|
|
+ let count = getNumberOfArchivedChats()
|
|
|
+ title.append(" (\(count))")
|
|
|
+ archiveCell.textLabel?.text = title
|
|
|
+ archiveCell.textLabel?.textColor = .systemBlue
|
|
|
+ return archiveCell
|
|
|
+ }
|
|
|
+
|
|
|
private func showDeleteChatConfirmationAlert(chatId: Int) {
|
|
|
let alert = UIAlertController(
|
|
|
title: nil,
|