Merge branch 'develop' of https://github.com/CatchChat/Yep into develop

This commit is contained in:
kevinzhow
2015-10-26 18:09:24 +08:00
19 changed files with 90 additions and 64 deletions
+6 -6
View File
@@ -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
+4 -25
View File
@@ -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() {
+5
View File
@@ -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(),
@@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "feed_media_placeholder_160.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "feed_media_placeholder_80.pdf"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
+5 -3
View File
@@ -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
+15 -9
View File
@@ -720,19 +720,25 @@ var isFetchingUnreadMessages = Listenable<Bool>(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)
}
}
}
})
}
}
@@ -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)
@@ -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)
@@ -34,14 +34,18 @@ 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
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) {
@@ -50,10 +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() {
@@ -123,7 +128,7 @@ class ConversationCell: UITableViewCell {
avatarImageView.navi_setAvatar(userAvatar)
} else {
avatarImageView.image = UIImage(named: "default_avatar")
avatarImageView.image = UIImage(named: "default_avatar_60")
}
}
@@ -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()
}
+2 -2
View File
@@ -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 {
@@ -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
}
}
@@ -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
}
@@ -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()
}
+1
View File
@@ -110,6 +110,7 @@ class FeedMediaView: UIView {
imageView2.image = nil
imageView3.image = nil
imageView4.image = nil
default:
break
}
+1 -1
View File
@@ -250,7 +250,7 @@ extension FeedView: UICollectionViewDataSource, UICollectionViewDelegate {
//println("attachment imageURL: \(imageURL)")
cell.configureWithImageURL(imageURL)
cell.configureWithImageURL(imageURL, bigger: (attachmentURLs.count == 1))
return cell
}