From 483d18008e470e194cc3e0d71374146a948111a8 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Mon, 26 Oct 2015 14:35:17 +0800 Subject: [PATCH 1/7] better syncUnreadMessages logic --- Yep/AppDelegate.swift | 29 ++++------------------------- Yep/Services/YepService.swift | 8 +++++--- Yep/Services/YepServiceSync.swift | 24 +++++++++++++++--------- 3 files changed, 24 insertions(+), 37 deletions(-) diff --git a/Yep/AppDelegate.swift b/Yep/AppDelegate.swift index a40082bb..e1788e36 100644 --- a/Yep/AppDelegate.swift +++ b/Yep/AppDelegate.swift @@ -223,11 +223,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { switch remoteNotificationType { case .Message: - if UIApplication.sharedApplication().applicationState == UIApplicationState.Active { - return - } - - syncUnreadMessage() + syncUnreadMessages() {} case .OfficialMessage: officialMessages { messagesCount in @@ -243,11 +239,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate { } } - completionHandler(UIBackgroundFetchResult.NewData) // 非前台才记录启动通知类型 if application.applicationState != .Active { self.remoteNotificationType = remoteNotificationType } + + completionHandler(UIBackgroundFetchResult.NewData) } else { completionHandler(UIBackgroundFetchResult.NoData) @@ -303,7 +300,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { syncFriendshipsAndDoFurtherAction { syncGroupsAndDoFurtherAction { [weak self] in - self?.syncUnreadMessage() + self?.syncUnreadMessages() {} } } @@ -311,24 +308,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate { println("new officialMessages count: \(messagesCount)") } } - - func syncUnreadMessage() { - let task = delay(0, work: { - syncUnreadMessagesAndDoFurtherAction { messageIDs in - tryPostNewMessagesReceivedNotificationWithMessageIDs(messageIDs, messageAge: .New) - } - }) - - delay(5) { [weak self] in - if let task = task { - if isFetchingUnreadMessages.value { - isFetchingUnreadMessages.value = false - task(cancel: true) - self?.syncUnreadMessage() - } - } - } - } func startFaye() { diff --git a/Yep/Services/YepService.swift b/Yep/Services/YepService.swift index 8eb5c202..3e70c27b 100644 --- a/Yep/Services/YepService.swift +++ b/Yep/Services/YepService.swift @@ -1535,7 +1535,7 @@ func officialMessages(completion completion: Int -> Void) { apiRequest({_ in}, baseURL: baseURL, resource: resource, failure: defaultFailureHandler, completion: completion) } -func headUnreadMessages(completion completion: JSONDictionary -> Void) { +func headUnreadMessages(failureHandler failureHandler: ((Reason, String?) -> Void)?, completion: JSONDictionary -> Void) { let requestParameters = [ "page": 1, "per_page": 100, @@ -1586,9 +1586,9 @@ func sentButUnreadMessages(failureHandler failureHandler: ((Reason, String?) -> } */ -func unreadMessages(completion completion: [JSONDictionary] -> Void) { +func unreadMessages(failureHandler failureHandler: ((Reason, String?) -> Void)?, completion: [JSONDictionary] -> Void) { - headUnreadMessages { result in + headUnreadMessages(failureHandler: failureHandler) { result in var messages = [JSONDictionary]() @@ -1615,6 +1615,8 @@ func unreadMessages(completion completion: [JSONDictionary] -> Void) { moreUnreadMessages(inPage: page, withPerPage: perPage, failureHandler: { (reason, errorMessage) in dispatch_group_leave(downloadGroup) + failureHandler?(reason, errorMessage) + }, completion: { result in if let currentPageMessages = result["messages"] as? [JSONDictionary] { messages += currentPageMessages diff --git a/Yep/Services/YepServiceSync.swift b/Yep/Services/YepServiceSync.swift index 5c889067..1e4d6951 100644 --- a/Yep/Services/YepServiceSync.swift +++ b/Yep/Services/YepServiceSync.swift @@ -720,19 +720,25 @@ var isFetchingUnreadMessages = Listenable(false) { _ in } func syncUnreadMessagesAndDoFurtherAction(furtherAction: (messageIDs: [String]) -> Void) { - println("Before fetching") - + if isFetchingUnreadMessages.value { + return + } + dispatch_async(dispatch_get_main_queue()) { - if isFetchingUnreadMessages.value { - return - } - isFetchingUnreadMessages.value = true println("Begin fetching") - unreadMessages { allUnreadMessages in + unreadMessages(failureHandler: { (reason, errorMessage) in + + defaultFailureHandler(reason, errorMessage: errorMessage) + + dispatch_async(dispatch_get_main_queue()) { + isFetchingUnreadMessages.value = false + } + + }, completion: { allUnreadMessages in //println("\n allUnreadMessages: \(allUnreadMessages)") println("Got unread message: \(allUnreadMessages.count)") @@ -751,13 +757,13 @@ func syncUnreadMessagesAndDoFurtherAction(furtherAction: (messageIDs: [String]) } } - dispatch_async(dispatch_get_main_queue()) { isFetchingUnreadMessages.value = false + furtherAction(messageIDs: messageIDs) } } - } + }) } } From d8538b40db7e33219e885191bd8cea458809934c Mon Sep 17 00:00:00 2001 From: nixzhu Date: Mon, 26 Oct 2015 16:47:20 +0800 Subject: [PATCH 2/7] fix showSkillHome from Feeds --- Yep/ViewControllers/Feeds/FeedsViewController.swift | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Yep/ViewControllers/Feeds/FeedsViewController.swift b/Yep/ViewControllers/Feeds/FeedsViewController.swift index 1137dfc7..f1604cfb 100644 --- a/Yep/ViewControllers/Feeds/FeedsViewController.swift +++ b/Yep/ViewControllers/Feeds/FeedsViewController.swift @@ -260,10 +260,8 @@ class FeedsViewController: UIViewController { let vc = segue.destinationViewController as! SkillHomeViewController - if let indexPath = sender as? NSIndexPath { - if let skill = feeds[indexPath.row].skill { - vc.skill = SkillCell.Skill(ID: skill.id, localName: skill.localName, coverURLString: skill.coverURLString, category: nil) - } + if let skill = skill { + vc.skill = SkillCell.Skill(ID: skill.id, localName: skill.localName, coverURLString: skill.coverURLString, category: nil) } vc.hidesBottomBarWhenPushed = true @@ -504,7 +502,7 @@ extension FeedsViewController: UITableViewDataSource, UITableViewDelegate { switch indexPath.section { case Section.SkillUsers.rawValue: - performSegueWithIdentifier("showSkillHome", sender: indexPath) + performSegueWithIdentifier("showSkillHome", sender: nil) case Section.Feed.rawValue: performSegueWithIdentifier("showConversation", sender: indexPath) From 16be53a8f2ba94055ce4ccddb9ddbbc0f538dfd3 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Mon, 26 Oct 2015 17:06:05 +0800 Subject: [PATCH 3/7] removeObserver --- Yep/Views/Cells/Conversation/ConversationCell.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Yep/Views/Cells/Conversation/ConversationCell.swift b/Yep/Views/Cells/Conversation/ConversationCell.swift index 42422599..392ca394 100644 --- a/Yep/Views/Cells/Conversation/ConversationCell.swift +++ b/Yep/Views/Cells/Conversation/ConversationCell.swift @@ -34,6 +34,11 @@ class ConversationCell: UITableViewCell { @IBOutlet weak var chatLabel: UILabel! @IBOutlet weak var timeAgoLabel: UILabel! + deinit { + + NSNotificationCenter.defaultCenter().removeObserver(self) + } + override func awakeFromNib() { super.awakeFromNib() // Initialization code From a9c4d67fc51664801180d10c96aa98a8466488f8 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Mon, 26 Oct 2015 17:07:32 +0800 Subject: [PATCH 4/7] default_avatar_60 --- Yep/Views/Cells/Conversation/ConversationCell.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Yep/Views/Cells/Conversation/ConversationCell.swift b/Yep/Views/Cells/Conversation/ConversationCell.swift index 392ca394..982b28f6 100644 --- a/Yep/Views/Cells/Conversation/ConversationCell.swift +++ b/Yep/Views/Cells/Conversation/ConversationCell.swift @@ -41,7 +41,6 @@ class ConversationCell: UITableViewCell { override func awakeFromNib() { super.awakeFromNib() - // Initialization code avatarImageView.contentMode = .ScaleAspectFill avatarImageViewWidthConstraint.constant = YepConfig.ConversationCell.avatarSize @@ -56,6 +55,7 @@ class ConversationCell: UITableViewCell { } func updateUIButAvatar(sender: NSNotification) { + updateCountOfUnreadMessages() updateInfoLabels() } @@ -128,7 +128,7 @@ class ConversationCell: UITableViewCell { avatarImageView.navi_setAvatar(userAvatar) } else { - avatarImageView.image = UIImage(named: "default_avatar") + avatarImageView.image = UIImage(named: "default_avatar_60") } } From 9ed7cef872706bed989a172aebf90b20280dca4c Mon Sep 17 00:00:00 2001 From: nixzhu Date: Mon, 26 Oct 2015 17:26:23 +0800 Subject: [PATCH 5/7] update pods (Navi & Kingfisher); update DribbbleShotCell & InstagramMediaCell --- Podfile.lock | 12 ++++++------ Yep/Views/Cells/DribbbleShot/DribbbleShotCell.swift | 2 +- .../Cells/InstagramMedia/InstagramMediaCell.swift | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Podfile.lock b/Podfile.lock index 4f1ab3ae..8de01668 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,6 +1,6 @@ PODS: - 1PasswordExtension (1.6.3) - - Alamofire (3.0.1) + - Alamofire (3.1.0) - APAddressBook/Core (0.2.1) - APAddressBook/Swift (0.2.1): - APAddressBook/Core @@ -13,12 +13,12 @@ PODS: - FXBlurView (1.6.4) - JPush (1.8.5) - KeyboardMan (0.5) - - Kingfisher (1.6.1) + - Kingfisher (1.7.0) - MonkeyKing (0.0.2) - MZFayeClient (1.0.1): - Base64 (~> 1.0.1) - SocketRocket (~> 0.4) - - Navi (0.3.6) + - Navi (0.3.7) - pop (1.0.8) - Proposer (0.7) - Realm (0.96.1): @@ -56,7 +56,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: 1PasswordExtension: 676a216461ffa9189db66541b5a2465e10ae4743 - Alamofire: 2457e1b2e6c46bb05c3a598c542b7bfd08893775 + Alamofire: 415bd7f56197722978759078486689f7ef913dce APAddressBook: 90c0fb07579a47e10ef1a2344e23cfd35f388bec Base64: 4924bf3ca6fa559a5161ef717291bd450eb7bd1a Crashlytics: 41c082440d2e14da444186fff65e79c0b4b35d4c @@ -65,10 +65,10 @@ SPEC CHECKSUMS: FXBlurView: db786c2561cb49a09ae98407f52460096ab8a44f JPush: ba06a6f866ce11f11c15149e7fa67488a23eec87 KeyboardMan: ae716dfb1252ebcd1f68a2b659e91a970110e799 - Kingfisher: a40cf8134ba1a78f395bdd3ee97d386ff3c3be0d + Kingfisher: 906bf9821bd32d06d4aaecc60431857e70ccabaa MonkeyKing: 9be24307843a80f4cd3eca66adc12c67aefb83bb MZFayeClient: 65e7ef67e61fbe7a7a8b196130541c9f06bcb5d8 - Navi: 73dd4e6cbe8b5aa107d00d1e500ce421c4ad20bd + Navi: 891defbce3c48dcf31d05d3c2cbc8b7fe6c77c30 pop: bb773ae2c791ca2629de13b347e7a8b450fa6a57 Proposer: c244e0d031227b6cf140da7a24d30f2d954d2cb2 Realm: d05e4621f67fb1c36acd4e573ac5b52a407fc2cc diff --git a/Yep/Views/Cells/DribbbleShot/DribbbleShotCell.swift b/Yep/Views/Cells/DribbbleShot/DribbbleShotCell.swift index b7597ac4..ab6a7701 100644 --- a/Yep/Views/Cells/DribbbleShot/DribbbleShotCell.swift +++ b/Yep/Views/Cells/DribbbleShot/DribbbleShotCell.swift @@ -23,7 +23,7 @@ class DribbbleShotCell: UICollectionViewCell { } func configureWithDribbbleShot(shot: DribbbleWork.Shot) { - imageView.kf_setImageWithURL(NSURL(string: shot.images.normal)!, placeholderImage: nil, optionsInfo: [.TargetCache: KingfisherOptions.CacheMemoryOnly], progressBlock: { receivedSize, totalSize in + imageView.kf_setImageWithURL(NSURL(string: shot.images.normal)!, placeholderImage: nil, optionsInfo: [], progressBlock: { receivedSize, totalSize in if receivedSize < totalSize { self.activityIndicator.startAnimating() } diff --git a/Yep/Views/Cells/InstagramMedia/InstagramMediaCell.swift b/Yep/Views/Cells/InstagramMedia/InstagramMediaCell.swift index 0a52b607..6a8dec81 100644 --- a/Yep/Views/Cells/InstagramMedia/InstagramMediaCell.swift +++ b/Yep/Views/Cells/InstagramMedia/InstagramMediaCell.swift @@ -23,7 +23,8 @@ class InstagramMediaCell: UICollectionViewCell { } func configureWithInstagramMedia(media: InstagramWork.Media) { - imageView.kf_setImageWithURL(NSURL(string: media.images.lowResolution)!, placeholderImage: nil, optionsInfo: [.TargetCache: KingfisherOptions.CacheMemoryOnly], progressBlock: { receivedSize, totalSize in + + imageView.kf_setImageWithURL(NSURL(string: media.images.lowResolution)!, placeholderImage: nil, optionsInfo: [], progressBlock: { receivedSize, totalSize in if receivedSize < totalSize { self.activityIndicator.startAnimating() } From b2484ac33fc6f605f5e86054b2d23f82cef65619 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Mon, 26 Oct 2015 17:42:34 +0800 Subject: [PATCH 6/7] FeedMedia's placeholderImage --- Yep/Configs/YepConfig.swift | 5 +++++ .../Contents.json | 12 ++++++++++++ .../feed_media_placeholder_160.pdf | Bin 0 -> 3902 bytes .../Contents.json | 12 ++++++++++++ .../feed_media_placeholder_80.pdf | Bin 0 -> 3893 bytes Yep/Views/Cells/Feed/FeedCell.swift | 4 ++-- Yep/Views/Cells/FeedMedia/FeedMediaCell.swift | 8 ++++++-- Yep/Views/Feed/FeedView.swift | 2 +- 8 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 Yep/Images.xcassets/feed_media_placeholder_160.imageset/Contents.json create mode 100644 Yep/Images.xcassets/feed_media_placeholder_160.imageset/feed_media_placeholder_160.pdf create mode 100644 Yep/Images.xcassets/feed_media_placeholder_80.imageset/Contents.json create mode 100644 Yep/Images.xcassets/feed_media_placeholder_80.imageset/feed_media_placeholder_80.pdf diff --git a/Yep/Configs/YepConfig.swift b/Yep/Configs/YepConfig.swift index a703f428..3cd4cc30 100644 --- a/Yep/Configs/YepConfig.swift +++ b/Yep/Configs/YepConfig.swift @@ -177,6 +177,11 @@ class YepConfig { // ] } + struct FeedMedia { + static let placeholderImage = UIImage(named: "feed_media_placeholder_80") + static let biggerPlaceholderImage = UIImage(named: "feed_media_placeholder_160") + } + struct FeedCell { static let textAttributes:[String: NSObject] = [ NSFontAttributeName: UIFont.feedMessageFont(), diff --git a/Yep/Images.xcassets/feed_media_placeholder_160.imageset/Contents.json b/Yep/Images.xcassets/feed_media_placeholder_160.imageset/Contents.json new file mode 100644 index 00000000..499feb0e --- /dev/null +++ b/Yep/Images.xcassets/feed_media_placeholder_160.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "feed_media_placeholder_160.pdf" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Yep/Images.xcassets/feed_media_placeholder_160.imageset/feed_media_placeholder_160.pdf b/Yep/Images.xcassets/feed_media_placeholder_160.imageset/feed_media_placeholder_160.pdf new file mode 100644 index 0000000000000000000000000000000000000000..9ac73dc38659ee5381f9c1f7affcf03eddaf449c GIT binary patch literal 3902 zcmai%c|6qp7RN197(yi?)h~}FC9@io-7qE!X))Gj#@Lx+vXwQJ*F_=68ELG2#V@%}E z-+5Kv2u1=>fJ|@%tEd1F1Cpy9#U4;#N@oCwu7fj$KXn5Ou7mQi&3HH5=EWxF9BzLGY0eYi7804%`m&iBmlj7r^2I%#d@#8%e5$-4 zt|JeZ-@~;d`@Fi!w@p8*Wq^9b(xXQ&k>E?9k0+v4Z*Su!(Yaw$FrNX)I&P$4bz28Tt{6;mwfPYVbH#cAR@AIJ46ev}$XddGdAGCP zmq-A_2yeIb>qc^=0EqAJd4}XpzT!qCxdW*0f;QQe!hG%yuyVsp#3_=E173^l1(-vb z0t~hFwFEPB@#7rUzMnZXaw8K>NEE=Fc^Fz3umm95WM{IQ$t66I1hA5UApi)P!i^zzIJ8a37! zqjeblR41O9LWTK()Qu+GVBgr&-afk--`)x~qxB$AEya{Q0GVkjG(Aycv1@m0{SwDs zL3Vyq_7_98wjj(hnxku-rkav+U$3!raaumWrt+O!wUM-Y&!&H@grc_Ob~dn1H%i4% zT7$WlJOy_X8j*#ed_#6itcS61L zb2t9T6=nN$Hm@AJkqA&YmXNcvH`#&lso8dQw$x;W06UsccWUTQF9Z5Q8Q%@4NI)_9 zrVhIl&Lzb@cB)W(Y6{mgYQIw5H+aC$WJ9&tXYJgq^dvo9lbVhjbe? zhbk|nv`(*`KanG%9{2}#4}zq_$jQyoN4K@{@h8!3HkJf8hhHc={MAw?cRS;S$ZW`` zbH<+%c!I<2D??NQO=IM3z`_3AL;ibFGF+m5X--1+SFG85LzIomv0Tk$RW|KEI3-=x zeK>q4%mrcK=BnrRg|Wr%(Quz{W2*;wEh1cp3^XN7Mi=>_ZQP{p%86zT20Pbq?26%{ z+yNs4<)IvM7k7vUATDtZ0BpeldV-ucIpy^@95g_WG}Yd)fi+=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_9hOcL;Rx80$!}>I~A(BG~quCJ#3&&W=&Mp+67nzV5d*d$I);hxce>j zF&^CtUA=M-Ih1<=b0VmZFwZQcGXjY187`1@7FI z&+xjspw=8R9~mwbcJd-csj6(`Oc&^2-laa+uA@jTk7XQC<$(%-kR@wZx52>8M9t|HEn~zcMujAHUJY~&jA)cd6tRRKbiP1 z@^=4cmS#e-2ZP5E08HD##+?DrOmJsd`vs5@O!WTUqB@>}cP86?hkExPH2)V;BM?7U z965_80(ypkF@S)}AP_PLz`z6VM)3t0guadX-V~{yej|Ri3`ejhk#GbC0Y}QhanWDAA^ z2oxCpzYCDXU{Dyq7Wko|&~V0im>1ysQ-dQ>j8y!tp%8M6M(B494o5PM^?w=?!ARNv zX($vU-M?!n1ey`~-!(WI{tx>i|27YW#4viJ-`Ap0@PE)SzwAqK!#g;W+_rmBLkC|* z{1^?;IWn11AIutH1X9b@mdq%Y?_(^ZTuu=XBs^LUfsx0{lQ0M*9)Tdr;cd|vxZDW@ g9*&Y#0{{Dz@8#xBVU)&pLQrTqSug~mp{EJ{FN#T#IsgCw literal 0 HcmV?d00001 diff --git a/Yep/Views/Cells/Feed/FeedCell.swift b/Yep/Views/Cells/Feed/FeedCell.swift index 6412da1c..3c3a91b1 100644 --- a/Yep/Views/Cells/Feed/FeedCell.swift +++ b/Yep/Views/Cells/Feed/FeedCell.swift @@ -224,7 +224,7 @@ extension FeedCell: UICollectionViewDataSource, UICollectionViewDelegate { //println("attachment imageURL: \(imageURL)") - cell.configureWithImageURL(imageURL) + cell.configureWithImageURL(imageURL, bigger: (attachmentURLs.count == 1)) } return cell @@ -234,10 +234,10 @@ extension FeedCell: UICollectionViewDataSource, UICollectionViewDelegate { if attachmentURLs.count > 1 { return CGSize(width: 80, height: 80) + } else { return CGSize(width: 160, height: 160) } - } func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAtIndex section: Int) -> UIEdgeInsets { diff --git a/Yep/Views/Cells/FeedMedia/FeedMediaCell.swift b/Yep/Views/Cells/FeedMedia/FeedMediaCell.swift index 81ec2f95..b571424d 100644 --- a/Yep/Views/Cells/FeedMedia/FeedMediaCell.swift +++ b/Yep/Views/Cells/FeedMedia/FeedMediaCell.swift @@ -27,9 +27,13 @@ class FeedMediaCell: UICollectionViewCell { deleteImageView.hidden = false } - func configureWithImageURL(imageURL: NSURL) { + func configureWithImageURL(imageURL: NSURL, bigger: Bool) { - imageView.kf_setImageWithURL(imageURL) + if bigger { + imageView.kf_setImageWithURL(imageURL, placeholderImage: YepConfig.FeedMedia.biggerPlaceholderImage) + } else { + imageView.kf_setImageWithURL(imageURL, placeholderImage: YepConfig.FeedMedia.placeholderImage) + } deleteImageView.hidden = true } diff --git a/Yep/Views/Feed/FeedView.swift b/Yep/Views/Feed/FeedView.swift index ab104a88..7ea12886 100644 --- a/Yep/Views/Feed/FeedView.swift +++ b/Yep/Views/Feed/FeedView.swift @@ -250,7 +250,7 @@ extension FeedView: UICollectionViewDataSource, UICollectionViewDelegate { //println("attachment imageURL: \(imageURL)") - cell.configureWithImageURL(imageURL) + cell.configureWithImageURL(imageURL, bigger: (attachmentURLs.count == 1)) return cell } From bba3479ee9bc0fd683eb429e127eca8f44cf4e5e Mon Sep 17 00:00:00 2001 From: nixzhu Date: Mon, 26 Oct 2015 17:57:57 +0800 Subject: [PATCH 7/7] thanks fixed bug in Navi, now reloadConversationsTableView will not flicker for avatars --- .../ConversationsViewController.swift | 2 ++ .../Cells/Conversation/ConversationCell.swift | 14 +++++++------- .../FeedConversationDockCell.swift | 3 +-- Yep/Views/Feed/FeedMediaView.swift | 1 + 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Yep/ViewControllers/Conversations/ConversationsViewController.swift b/Yep/ViewControllers/Conversations/ConversationsViewController.swift index fd772778..6cab1a15 100644 --- a/Yep/ViewControllers/Conversations/ConversationsViewController.swift +++ b/Yep/ViewControllers/Conversations/ConversationsViewController.swift @@ -75,6 +75,8 @@ 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.changedConversation, object: nil) NSNotificationCenter.defaultCenter().addObserver(self, selector: "reloadConversationsTableView", name: YepConfig.Notification.markAsReaded, object: nil) diff --git a/Yep/Views/Cells/Conversation/ConversationCell.swift b/Yep/Views/Cells/Conversation/ConversationCell.swift index 982b28f6..5efc8407 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() { diff --git a/Yep/Views/Cells/FeedConversationDock/FeedConversationDockCell.swift b/Yep/Views/Cells/FeedConversationDock/FeedConversationDockCell.swift index f5567c0f..4a3a85ad 100644 --- a/Yep/Views/Cells/FeedConversationDock/FeedConversationDockCell.swift +++ b/Yep/Views/Cells/FeedConversationDock/FeedConversationDockCell.swift @@ -26,7 +26,6 @@ class FeedConversationDockCell: UITableViewCell { super.awakeFromNib() nameLabel.text = NSLocalizedString("Joined Feeds", comment: "") - accessoryImageView.tintColor = UIColor.yepCellAccessoryImageViewTintColor() } @@ -35,5 +34,5 @@ class FeedConversationDockCell: UITableViewCell { // Configure the view for the selected state } - } + diff --git a/Yep/Views/Feed/FeedMediaView.swift b/Yep/Views/Feed/FeedMediaView.swift index c3680ad2..a063294e 100644 --- a/Yep/Views/Feed/FeedMediaView.swift +++ b/Yep/Views/Feed/FeedMediaView.swift @@ -110,6 +110,7 @@ class FeedMediaView: UIView { imageView2.image = nil imageView3.image = nil imageView4.image = nil + default: break }