createFeedWithKind GithubRepo

This commit is contained in:
nixzhu
2015-11-21 09:52:11 +08:00
parent 1c316f5fb8
commit ccfd59212e
2 changed files with 32 additions and 14 deletions
+1 -5
View File
@@ -2733,7 +2733,7 @@ enum FeedKind: String {
//case InstagramMedia = "instagram"
}
func createFeedWithKind(kind: FeedKind, message: String, attachments: JSONDictionary?, sharedStuff: JSONDictionary?, coordinate: CLLocationCoordinate2D?, skill: Skill?, allowComment: Bool, failureHandler: ((Reason, String?) -> Void)?, completion: JSONDictionary -> Void) {
func createFeedWithKind(kind: FeedKind, message: String, attachments: JSONDictionary?, coordinate: CLLocationCoordinate2D?, skill: Skill?, allowComment: Bool, failureHandler: ((Reason, String?) -> Void)?, completion: JSONDictionary -> Void) {
var requestParameters: JSONDictionary = [
"kind": kind.rawValue,
@@ -2756,10 +2756,6 @@ func createFeedWithKind(kind: FeedKind, message: String, attachments: JSONDictio
requestParameters["attachments"] = attachments
}
if let sharedStuff = sharedStuff {
requestParameters["shared_stuff"] = sharedStuff
}
let parse: JSONDictionary -> JSONDictionary? = { data in
return data
}
@@ -380,13 +380,6 @@ class NewFeedViewController: UIViewController {
func post(sender: UIBarButtonItem) {
guard socialWork == nil else {
YepAlert.alertSorry(message: "Can NOT post Feed with Social Work yet.", inViewController: self)
return
}
messageTextView.resignFirstResponder()
let messageLength = (messageTextView.text as NSString).length
@@ -486,9 +479,38 @@ class NewFeedViewController: UIViewController {
}
let kind: FeedKind = uploadImageInfos.isEmpty ? . Text : .Image
var kind: FeedKind = uploadImageInfos.isEmpty ? .Text : .Image
createFeedWithKind(kind, message: message, attachments: mediaInfo, sharedStuff: nil, coordinate: coordinate, skill: self?.pickedSkill, allowComment: true, failureHandler: { [weak self] reason, errorMessage in
if let socialWork = self?.socialWork {
guard let type = MessageSocialWorkType(rawValue: socialWork.type) else {
return
}
switch type {
case .GithubRepo:
guard let githubRepo = socialWork.githubRepo else {
break
}
mediaInfo = [
"github": [[
"name": githubRepo.name,
"full_name": githubRepo.fullName,
"description": githubRepo.repoDescription,
"url": githubRepo.URLString,
]]
]
kind = .GithubRepo
default:
break
}
}
createFeedWithKind(kind, message: message, attachments: mediaInfo, 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)