From db6edf399ee534f6f4f60a7fabe7d3af598aa3fc Mon Sep 17 00:00:00 2001 From: nixzhu Date: Wed, 11 Nov 2015 16:34:38 +0800 Subject: [PATCH] do not reloadConversationsTableView when receive new message, instead updateUIButAvatar in ConversationCell --- .../ConversationsViewController.swift | 2 +- .../Cells/Conversation/ConversationCell.swift | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Yep/ViewControllers/Conversations/ConversationsViewController.swift b/Yep/ViewControllers/Conversations/ConversationsViewController.swift index f670b78e..9890ca8a 100644 --- a/Yep/ViewControllers/Conversations/ConversationsViewController.swift +++ b/Yep/ViewControllers/Conversations/ConversationsViewController.swift @@ -80,7 +80,7 @@ class ConversationsViewController: UIViewController { realm = try! Realm() - NSNotificationCenter.defaultCenter().addObserver(self, selector: "reloadConversationsTableView", name: YepConfig.Notification.newMessages, object: nil) + //NSNotificationCenter.defaultCenter().addObserver(self, selector: "reloadConversationsTableView", name: YepConfig.Notification.newMessages, object: nil) NSNotificationCenter.defaultCenter().addObserver(self, selector: "reloadConversationsTableView", name: YepConfig.Notification.changedConversation, object: nil) diff --git a/Yep/Views/Cells/Conversation/ConversationCell.swift b/Yep/Views/Cells/Conversation/ConversationCell.swift index 1950d9d4..f9ea4b8f 100644 --- a/Yep/Views/Cells/Conversation/ConversationCell.swift +++ b/Yep/Views/Cells/Conversation/ConversationCell.swift @@ -36,7 +36,7 @@ class ConversationCell: UITableViewCell { deinit { - //NSNotificationCenter.defaultCenter().removeObserver(self) + NSNotificationCenter.defaultCenter().removeObserver(self) } override func awakeFromNib() { @@ -45,7 +45,7 @@ class ConversationCell: UITableViewCell { avatarImageView.contentMode = .ScaleAspectFill avatarImageViewWidthConstraint.constant = YepConfig.ConversationCell.avatarSize - //NSNotificationCenter.defaultCenter().addObserver(self, selector: "updateUIButAvatar:", name: YepConfig.Notification.newMessages, object: nil) + NSNotificationCenter.defaultCenter().addObserver(self, selector: "updateUIButAvatar:", name: YepConfig.Notification.newMessages, object: nil) } override func setSelected(selected: Bool, animated: Bool) { @@ -54,11 +54,11 @@ class ConversationCell: UITableViewCell { // Configure the view for the selected state } -// func updateUIButAvatar(sender: NSNotification) { -// -// updateCountOfUnreadMessages() -// updateInfoLabels() -// } + func updateUIButAvatar(sender: NSNotification) { + + updateCountOfUnreadMessages() + updateInfoLabels() + } private func updateCountOfUnreadMessages() {