瀏覽代碼

Deleting chats now possible

Bastian van de Wetering 6 年之前
父節點
當前提交
d7726f0bea
共有 1 個文件被更改,包括 19 次插入0 次删除
  1. 19 0
      deltachat-ios/Controller/ChatListController.swift

+ 19 - 0
deltachat-ios/Controller/ChatListController.swift

@@ -170,4 +170,23 @@ extension ChatListController: UITableViewDataSource, UITableViewDelegate {
       coordinator?.showChat(chatId: chatId)
     }
   }
+
+
+	func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
+		let section = indexPath.section
+		let row = indexPath.row
+		guard let chatList = chatList else {
+			return nil
+		}
+
+		// assigning swipe by delete to chats
+		let delete = UITableViewRowAction(style: .destructive, title: "Delete") { [unowned self] _, indexPath in
+			let chatId = chatList.getChatId(index: row)
+			dc_delete_chat(mailboxPointer, UInt32(chatId))
+			self.getChatList()
+
+		}
+		delete.backgroundColor = UIColor.red
+		return [delete]
+	}
 }