diff --git a/Yep/Services/YepService.swift b/Yep/Services/YepService.swift index b6eba5d3..3ba59a5f 100644 --- a/Yep/Services/YepService.swift +++ b/Yep/Services/YepService.swift @@ -2587,7 +2587,6 @@ struct DiscoveredFeed: Hashable { updatedUnixTime = feedInfo["updated_at"] as? NSTimeInterval, creatorInfo = feedInfo["user"] as? JSONDictionary, body = feedInfo["body"] as? String, - attachmentsData = feedInfo["attachments"] as? [JSONDictionary], messagesCount = feedInfo["message_count"] as? Int else { return nil } @@ -2604,7 +2603,8 @@ struct DiscoveredFeed: Hashable { let distance = feedInfo["distance"] as? Double - let attachments = attachmentsData.map({ DiscoveredAttachment.fromJSONDictionary($0) }).flatMap({ $0 }) + let attachmentsData = feedInfo["attachments"] as? [JSONDictionary] + let attachments = attachmentsData?.map({ DiscoveredAttachment.fromJSONDictionary($0) }).flatMap({ $0 }) ?? [] var skill: Skill? if let skillInfo = feedInfo["skill"] as? JSONDictionary { @@ -2718,7 +2718,11 @@ func feedsOfUser(userID: String, pageIndex: Int, perPage: Int, failureHandler: ( } enum FeedKind: String { - case Normal = "normal" + case Text = "text" + case Image = "image" + case Video = "video" + case Audio = "audio" + case Location = "location" case AppleMusic = "apple_music" case AppleMovie = "apple_movie" diff --git a/Yep/ViewControllers/Feeds/FeedsViewController.swift b/Yep/ViewControllers/Feeds/FeedsViewController.swift index 372ef958..c5063f97 100644 --- a/Yep/ViewControllers/Feeds/FeedsViewController.swift +++ b/Yep/ViewControllers/Feeds/FeedsViewController.swift @@ -117,8 +117,6 @@ class FeedsViewController: BaseViewController { let height: CGFloat switch feed.kind { - case .Normal: - height = FeedCell.heightOfFeed(feed) case .GithubRepo, .DribbbleShot: height = FeedSocialWorkCell.heightOfFeed(feed) default: @@ -591,9 +589,6 @@ extension FeedsViewController: UITableViewDataSource, UITableViewDelegate { let feed = feeds[indexPath.row] switch feed.kind { - case .Normal: - let cell = tableView.dequeueReusableCellWithIdentifier(feedCellID) as! FeedCell - return cell case .GithubRepo, .DribbbleShot: let cell = tableView.dequeueReusableCellWithIdentifier(feedSocialWorkCellID) as! FeedSocialWorkCell @@ -631,7 +626,12 @@ extension FeedsViewController: UITableViewDataSource, UITableViewDelegate { switch feed.kind { - case .Normal: + case .GithubRepo, .DribbbleShot: + guard let cell = cell as? FeedSocialWorkCell else { + break + } + + default: guard let cell = cell as? FeedCell else { break @@ -715,14 +715,6 @@ extension FeedsViewController: UITableViewDataSource, UITableViewDelegate { } tableView.deselectRowAtIndexPath(indexPath, animated: true) } - - case .GithubRepo, .DribbbleShot: - guard let cell = cell as? FeedSocialWorkCell else { - break - } - - default: - break } case Section.LoadMore.rawValue: diff --git a/Yep/ViewControllers/NewFeed/NewFeedViewController.swift b/Yep/ViewControllers/NewFeed/NewFeedViewController.swift index a00e0c69..cdf049b5 100644 --- a/Yep/ViewControllers/NewFeed/NewFeedViewController.swift +++ b/Yep/ViewControllers/NewFeed/NewFeedViewController.swift @@ -486,7 +486,7 @@ class NewFeedViewController: UIViewController { } - createFeedWithKind(.Normal, message: message, attachments: mediaInfo, sharedStuff: nil, coordinate: coordinate, skill: self?.pickedSkill, allowComment: true, failureHandler: { [weak self] reason, errorMessage in + createFeedWithKind(.Image, message: message, attachments: mediaInfo, sharedStuff: nil, coordinate: coordinate, skill: self?.pickedSkill, allowComment: true, failureHandler: { [weak self] reason, errorMessage in defaultFailureHandler(reason, errorMessage: errorMessage) YepAlert.alertSorry(message: errorMessage ?? NSLocalizedString("Create feed failed!", comment: ""), inViewController: self)