         }
         
         // 防止未在此界面时被标记
+            
+        var messages = conversation.messages.filter({ message in
+            if let fromFriend = message.fromFriend {
+                return (message.readed == false) && (fromFriend.friendState != UserFriendState.Me.rawValue)
+            } else {
+                return false
+            }
+        })
+
+        for message in messages {
+            markMessageAsReaded(message)
+        }
+
+    }
+    
+    func markMessageAsReaded(message: Message) {
+        
         if navigationController?.topViewController == self {
-            
-            var messages = conversation.messages.filter({ message in
-                if let fromFriend = message.fromFriend {
-                    return (message.readed == false) && (fromFriend.friendState != UserFriendState.Me.rawValue)
-                } else {
-                    return false
-                }
-            })
-
-            for message in messages {
-                markAsReadMessage(message, failureHandler: nil) { success in
-                    dispatch_async(dispatch_get_main_queue()) {
-                        let realm = Realm()
+        
+            markAsReadMessage(message, failureHandler: nil) { success in
+                dispatch_async(dispatch_get_main_queue()) {
+                    let realm = Realm()
+                    
+                    if let message = messageWithMessageID(message.messageID, inRealm: realm) {
+                        realm.write {
+                            message.readed = true
+                        }
                         
-                        if let message = messageWithMessageID(message.messageID, inRealm: realm) {
-                            realm.write {
-                                message.readed = true
-                            }
-                            
-                            println("\(message.messageID) mark as read")
-                        }
+                        println("\(message.messageID) mark as read")
                     }
                 }
-
-            }
-        }
+            }
+        }
+
     }
 
     override func viewDidDisappear(animated: Bool) {


                // TODO: 需要更好的下载与 mark as read 逻辑：也许未下载的也可以 mark as read
                downloadAttachmentOfMessage(message)

                switch message.mediaType {
                case MessageMediaType.Image.rawValue:

    
    func updateMessagesStates() {

        self.delay(0.1) {

            self.removeSendStates()

