Skip to content

Commit

Permalink
Display gravatar from SUSI API instead of gravatar API
Browse files Browse the repository at this point in the history
  • Loading branch information
jogendra committed Oct 2, 2018
1 parent f724888 commit 53b44e7
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 279 deletions.
4 changes: 0 additions & 4 deletions Susi.xcodeproj/project.pbxproj
Expand Up @@ -23,7 +23,6 @@
407EFAC020C34C0000675A0B /* LanguagePickerController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 407EFABF20C34C0000675A0B /* LanguagePickerController.swift */; };
40801EE320F33B4C0071860E /* VideoPlayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40801EE220F33B4C0071860E /* VideoPlayerView.swift */; };
40801EE520F33BBB0071860E /* YTPlayer.html in Resources */ = {isa = PBXBuildFile; fileRef = 40801EE420F33BBB0071860E /* YTPlayer.html */; };
408CDD72211DDCD100C836F0 /* MD5Digest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 408CDD71211DDCD100C836F0 /* MD5Digest.swift */; };
40D8882120CA9DBA006226EE /* TEABarChart.m in Sources */ = {isa = PBXBuildFile; fileRef = 40D8881720CA9DB9006226EE /* TEABarChart.m */; };
40DE743620E39E52003C0116 /* FeedbackDisplayCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40DE743520E39E52003C0116 /* FeedbackDisplayCell.swift */; };
40DE743920E49F3A003C0116 /* AllFeedbackViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40DE743820E49F3A003C0116 /* AllFeedbackViewController.swift */; };
Expand Down Expand Up @@ -141,7 +140,6 @@
407EFABF20C34C0000675A0B /* LanguagePickerController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LanguagePickerController.swift; sourceTree = "<group>"; };
40801EE220F33B4C0071860E /* VideoPlayerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoPlayerView.swift; sourceTree = "<group>"; };
40801EE420F33BBB0071860E /* YTPlayer.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = YTPlayer.html; sourceTree = "<group>"; };
408CDD71211DDCD100C836F0 /* MD5Digest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MD5Digest.swift; sourceTree = "<group>"; };
40D8881720CA9DB9006226EE /* TEABarChart.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TEABarChart.m; sourceTree = "<group>"; };
40D8881C20CA9DB9006226EE /* TEAChart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TEAChart.h; sourceTree = "<group>"; };
40D8881F20CA9DBA006226EE /* TEABarChart.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TEABarChart.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -582,7 +580,6 @@
6DE44E0E1E769AD300215B85 /* Color.swift */,
4CD0AA5E1EDF2CB700BC8FD5 /* ControllerConstants.swift */,
6D4D9B531E7690160067459C /* Extensions.swift */,
408CDD71211DDCD100C836F0 /* MD5Digest.swift */,
);
path = Helpers;
sourceTree = "<group>";
Expand Down Expand Up @@ -995,7 +992,6 @@
6D8AC7BA1F205F7F00FAA335 /* CollectionViewDelegate.swift in Sources */,
6DE809D11F34DC6500CAE674 /* TrainingAudioRecorderDelegate.swift in Sources */,
6DCA90641F1F0B320058CABB /* TextFieldDelegate.swift in Sources */,
408CDD72211DDCD100C836F0 /* MD5Digest.swift in Sources */,
6DE44E191E76AF8100215B85 /* ChatViewController.swift in Sources */,
6D61B9B31EEBAB4000CD3536 /* TableAction.swift in Sources */,
6D87A3321EEE86CC00A6D763 /* RSSCell.swift in Sources */,
Expand Down
13 changes: 3 additions & 10 deletions Susi/Custom Views/Feedback Display Cell/AllFeedbackCell.swift
Expand Up @@ -27,8 +27,9 @@ class AllFeedbackCell: UITableViewCell {
}
feedbackDateLabel.text = feedback?.timeStamp.getFirstChar(10)
userFeedbackLabel.text = feedback?.feedbackString
if let userEmail = feedback?.email {
setGravatar(from: userEmail)
if let avatarURLString = feedback?.avatar {
let imageURL = URL(string: avatarURLString)
gravatarImageView.kf.setImage(with: imageURL)
}
roundedCorner()
}
Expand All @@ -41,12 +42,4 @@ class AllFeedbackCell: UITableViewCell {
gravatarImageView.layer.masksToBounds = true
}

func setGravatar(from emailString: String) {
let baseGravatarURL = "https://www.gravatar.com/avatar/"
let emailMD5 = emailString.utf8.md5.rawValue
let imageString = baseGravatarURL + emailMD5 + ".jpg"
let imageURL = URL(string: imageString)
gravatarImageView.kf.setImage(with: imageURL)
}

}
13 changes: 3 additions & 10 deletions Susi/Custom Views/Feedback Display Cell/FeedbackDisplayCell.swift
Expand Up @@ -26,8 +26,9 @@ class FeedbackDisplayCell: UITableViewCell {
}
feedbackDateLabel.text = feedback?.timeStamp.getFirstChar(10)
userFeedbackLabel.text = feedback?.feedbackString
if let userEmail = feedback?.email {
setGravatar(from: userEmail)
if let avatarURLString = feedback?.avatar {
let imageURL = URL(string: avatarURLString)
gravatarImageView.kf.setImage(with: imageURL)
}
roundedCorner()
}
Expand All @@ -40,12 +41,4 @@ class FeedbackDisplayCell: UITableViewCell {
gravatarImageView.layer.masksToBounds = true
}

func setGravatar(from emailString: String) {
let baseGravatarURL = "https://www.gravatar.com/avatar/"
let emailMD5 = emailString.utf8.md5.rawValue
let imageString = baseGravatarURL + emailMD5 + ".jpg"
let imageURL = URL(string: imageString)
gravatarImageView.kf.setImage(with: imageURL)
}

}
255 changes: 0 additions & 255 deletions Susi/Helpers/MD5Digest.swift

This file was deleted.

2 changes: 2 additions & 0 deletions Susi/Model/Feedback.swift
Expand Up @@ -13,13 +13,15 @@ class Feedback: NSObject {
var email: String = ""
var timeStamp: String = ""
var username: String?
var avatar: String = ""

convenience init(dictionary: [String: AnyObject]) {
self.init()
feedbackString = dictionary["feedback"] as? String ?? ""
email = dictionary["email"] as? String ?? ""
timeStamp = dictionary["timestamp"] as? String ?? ""
username = dictionary["user_name"] as? String
avatar = dictionary["avatar"] as? String ?? ""
}

static func getAllFeedback(_ feedbacks: [Dictionary<String, AnyObject>]) -> [Feedback] {
Expand Down

0 comments on commit 53b44e7

Please sign in to comment.