Преглед изворни кода

Merge pull request #68 from deltachat/DeleteChats

Delete Chat Feature
nayooti пре 6 година
родитељ
комит
031fb51f46
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]
+	}
 }