From 021663e170a2147dddf02efbb6add3c167d9d250 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Wed, 11 Nov 2015 17:15:49 +0800 Subject: [PATCH] rename messagesCount of Feed --- Yep/AppDelegate.swift | 2 +- Yep/Realm/Models.swift | 4 ++-- Yep/Services/YepService.swift | 6 +++--- Yep/ViewControllers/Feeds/FeedsViewController.swift | 2 +- Yep/Views/Cells/Feed/FeedCell.swift | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Yep/AppDelegate.swift b/Yep/AppDelegate.swift index 65a795e8..b3e5971f 100644 --- a/Yep/AppDelegate.swift +++ b/Yep/AppDelegate.swift @@ -41,7 +41,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { let directory: NSURL = NSFileManager.defaultManager().containerURLForSecurityApplicationGroupIdentifier(YepConfig.appGroupID)! let realmPath = directory.URLByAppendingPathComponent("db.realm").path! - return Realm.Configuration(path: realmPath, schemaVersion: 5, migrationBlock: { migration, oldSchemaVersion in + return Realm.Configuration(path: realmPath, schemaVersion: 6, migrationBlock: { migration, oldSchemaVersion in }) } diff --git a/Yep/Realm/Models.swift b/Yep/Realm/Models.swift index 08783360..c74839b0 100644 --- a/Yep/Realm/Models.swift +++ b/Yep/Realm/Models.swift @@ -504,7 +504,7 @@ class Feed: Object { dynamic var creator: User? dynamic var distance: Double = 0 - dynamic var messageCount: Int = 0 + dynamic var messagesCount: Int = 0 dynamic var body: String = "" var attachments = List() @@ -681,7 +681,7 @@ func saveFeedWithFeedDataWithFullGroup(feedData: DiscoveredFeed, group: Group, i newFeed.distance = distance } - newFeed.messageCount = feedData.messageCount + newFeed.messagesCount = feedData.messagesCount if let feedSkill = feedData.skill { let _ = try? realm.write { diff --git a/Yep/Services/YepService.swift b/Yep/Services/YepService.swift index 1eb44388..8dc198a2 100644 --- a/Yep/Services/YepService.swift +++ b/Yep/Services/YepService.swift @@ -2504,7 +2504,7 @@ struct DiscoveredFeed: Hashable { let skill: Skill? let groupID: String - var messageCount: Int + var messagesCount: Int static func fromJSONDictionary(json: JSONDictionary) -> DiscoveredFeed? { @@ -2518,7 +2518,7 @@ struct DiscoveredFeed: Hashable { attachmentsData = json["attachments"] as? [JSONDictionary], //skill // TODO: skill groupInfo = json["circle"] as? JSONDictionary, - messageCount = json["message_count"] as? Int else { + messagesCount = json["message_count"] as? Int else { return nil } @@ -2535,7 +2535,7 @@ struct DiscoveredFeed: Hashable { skill = Skill.fromJSONDictionary(skillInfo) } - return DiscoveredFeed(id: id, allowComment: allowComment, createdUnixTime: createdUnixTime, updatedUnixTime: updatedUnixTime, creator: creator, body: body, attachments: attachments, distance: distance, skill: skill, groupID: groupID, messageCount: messageCount) + return DiscoveredFeed(id: id, allowComment: allowComment, createdUnixTime: createdUnixTime, updatedUnixTime: updatedUnixTime, creator: creator, body: body, attachments: attachments, distance: distance, skill: skill, groupID: groupID, messagesCount: messagesCount) } } diff --git a/Yep/ViewControllers/Feeds/FeedsViewController.swift b/Yep/ViewControllers/Feeds/FeedsViewController.swift index 8fbf486e..5a1238e4 100644 --- a/Yep/ViewControllers/Feeds/FeedsViewController.swift +++ b/Yep/ViewControllers/Feeds/FeedsViewController.swift @@ -473,7 +473,7 @@ class FeedsViewController: BaseViewController { guard var updatedFeed = self?.feeds[safe: index] else { return } - updatedFeed.messageCount += newMessagesCount + updatedFeed.messagesCount += newMessagesCount self?.feeds.removeAtIndex(index) self?.feeds.insert(updatedFeed, atIndex: index) diff --git a/Yep/Views/Cells/Feed/FeedCell.swift b/Yep/Views/Cells/Feed/FeedCell.swift index c3db4b03..76bb8297 100644 --- a/Yep/Views/Cells/Feed/FeedCell.swift +++ b/Yep/Views/Cells/Feed/FeedCell.swift @@ -216,7 +216,7 @@ class FeedCell: UITableViewCell { } timeLabel.text = "\(NSDate(timeIntervalSince1970: feed.createdUnixTime).timeAgo)" - messageCountLabel.text = "\(feed.messageCount)" + messageCountLabel.text = "\(feed.messagesCount)" } }