|
@@ -18,6 +18,7 @@ class ChatListController: UIViewController {
|
|
private var msgChangedObserver: Any?
|
|
private var msgChangedObserver: Any?
|
|
private var incomingMsgObserver: Any?
|
|
private var incomingMsgObserver: Any?
|
|
private var viewChatObserver: Any?
|
|
private var viewChatObserver: Any?
|
|
|
|
+ private var deleteChatObserver: Any?
|
|
|
|
|
|
private var newButton: UIBarButtonItem!
|
|
private var newButton: UIBarButtonItem!
|
|
|
|
|
|
@@ -60,6 +61,12 @@ class ChatListController: UIViewController {
|
|
self.coordinator?.showChat(chatId: chatId)
|
|
self.coordinator?.showChat(chatId: chatId)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ deleteChatObserver = nc.addObserver(forName: dcNotificationChatDeletedInChatDetail, object: nil, queue: nil) { notification in
|
|
|
|
+ if let chatId = notification.userInfo?["chat_id"] as? Int {
|
|
|
|
+ self.deleteChat(chatId: chatId)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
override func viewDidDisappear(_ animated: Bool) {
|
|
override func viewDidDisappear(_ animated: Bool) {
|
|
@@ -300,10 +307,14 @@ extension ChatListController: UITableViewDataSource, UITableViewDelegate {
|
|
preferredStyle: .safeActionSheet
|
|
preferredStyle: .safeActionSheet
|
|
)
|
|
)
|
|
alert.addAction(UIAlertAction(title: String.localized("menu_delete_chat"), style: .destructive, handler: { _ in
|
|
alert.addAction(UIAlertAction(title: String.localized("menu_delete_chat"), style: .destructive, handler: { _ in
|
|
- self.dcContext.deleteChat(chatId: chatId)
|
|
|
|
- self.getChatList()
|
|
|
|
|
|
+ self.deleteChat(chatId: chatId)
|
|
}))
|
|
}))
|
|
alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: nil))
|
|
alert.addAction(UIAlertAction(title: String.localized("cancel"), style: .cancel, handler: nil))
|
|
self.present(alert, animated: true, completion: nil)
|
|
self.present(alert, animated: true, completion: nil)
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private func deleteChat(chatId: Int) {
|
|
|
|
+ self.dcContext.deleteChat(chatId: chatId)
|
|
|
|
+ self.getChatList()
|
|
|
|
+ }
|
|
}
|
|
}
|