                     guard let messageRef = weakSelf.ref else {return}
                     weakSelf.updateReadMsgCount(forRefrence: messageRef.childByAppendingPath(id))
                 }
-                
-            }
-            
+            }
             }, withCancelBlock: { error in
                 print(error.description)
         })

        self.tableView.addGestureRecognizer(tap)
        ref = Firebase(url:Constants.FIREBASE_BASE_URL.stringByAppendingString("/chats/\(chat?.channelName ?? "")/messages"))
        channelRef = Firebase(url:Constants.FIREBASE_BASE_URL.stringByAppendingString("/chats/\(chat?.channelName ?? "")"))
        
        
        
        
        
        //        channelRef?.observeSingleEventOfType(.Value, withBlock: { snapshot in
        //            print(snapshot.value["totalCount"] )
        //            print(snapshot.value["unreadCount"])
        //        })
        
    }
    
    override func didReceiveMemoryWarning() {

                weakSelf.chatMessages.removeAtIndex(index!)
                weakSelf.tableView.deleteRowsAtIndexPaths([NSIndexPath(forRow: index!, inSection: 0)], withRowAnimation: .Automatic)
            }
        })
    }
    
    func registerMsgChangedObserver() {
