     }
 
     func addChat(chat: Chat) {
-        model.append(chat)
-        let path = NSIndexPath(forRow: self.model.count-1, inSection: 0)
+        fullModel.append(chat)
+        //TODO: only add to search model if chat matches search string by some criteria
+        searchModel?.append(chat)
+        let path = NSIndexPath(forRow: self.activeModel.count-1, inSection: 0)
         self.tableView.insertRowsAtIndexPaths([path], withRowAnimation: .None)
+    }
+
+    func searchBarTextDidBeginEditing(searchBar: UISearchBar) {
+        searchBar.setShowsCancelButton(true, animated: true)
+    }
+
+    func searchBarCancelButtonClicked(searchBar: UISearchBar) {
+        self.searchModel = nil
+        self.tableView.reloadData()
+
+        searchBar.text = nil
+        searchBar.setShowsCancelButton(false, animated: true)
+        searchBar.resignFirstResponder()
     }
 
     func searchBarSearchButtonClicked(searchBar: UISearchBar) {
         ChatClient.getList(search: searchBar.text, success: { chats in
-            self.model = chats
+            self.searchModel = chats
             self.tableView.reloadData()
         })
+
+        searchBar.setShowsCancelButton(false, animated: true)
         searchBar.resignFirstResponder()
     }
 

    }

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return model.count
    }

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! ChatCell

        cell.inject(chat: model[indexPath.row])

        return cell
    }


    @IBOutlet private var tableView: UITableView!

    private var searchModel: [Chat]?
    private var fullModel = [Chat]()
    private var activeModel: [Chat] {
        get {
            return searchModel ?? fullModel
        }
    }
    private var cellIdentifier = "ChatCell"
    private var plusButtonHeight: CGFloat = 72

    override func viewDidLoad() {
        ChatClient.getList(success: { chats in
            self.fullModel = chats
            self.tableView.reloadData()
        })

