Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
nixzhu
2015-04-21 21:15:33 +08:00
5 changed files with 31 additions and 11 deletions
+5 -3
View File
@@ -93,9 +93,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
func application(application: UIApplication, performFetchWithCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
syncUnreadMessages() {
completionHandler(UIBackgroundFetchResult.NewData)
}
}
// MARK: APNs
@@ -119,12 +121,12 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
println("didReceiveRemoteNotification: \(userInfo)")
if let v1AccessToken = YepUserDefaults.v1AccessToken() {
APService.handleRemoteNotification(userInfo)
if let type = userInfo["type"] as? String {
if type == "message" {
syncUnreadMessages() {
completionHandler(UIBackgroundFetchResult.NewData)
APService.handleRemoteNotification(userInfo)
}
}
}
+1 -1
View File
@@ -961,7 +961,7 @@ func sendMessageWithMediaType(mediaType: MessageMediaType, inFilePath filePath:
func markAsReadMessage(message: Message ,#failureHandler: ((Reason, String?) -> Void)?, #completion: (Bool) -> Void) {
if message.readed || message.messageID.isEmpty || message.downloadState != MessageDownloadState.Downloaded.rawValue {
if message.readed || message.messageID.isEmpty {
return
}
+2 -1
View File
@@ -365,7 +365,8 @@ private func syncGroupWithGroupInfo(groupInfo: JSONDictionary, inRealm realm: RL
func syncUnreadMessagesAndDoFurtherAction(furtherAction: () -> Void) {
unreadMessages { allUnreadMessages in
//println("\n allUnreadMessages: \(allUnreadMessages)")
println("Got unread message \(allUnreadMessages.count)")
dispatch_async(realmQueue) {
let realm = RLMRealm.defaultRealm()
@@ -18,7 +18,7 @@ class ConversationViewController: UIViewController {
return messagesInConversation(self.conversation)
}()
let messagesBunchCount = 12 // TODO:
let messagesBunchCount = 50 // TODO:
var displayedMessagesRange = NSRange()
@@ -401,11 +401,11 @@ class ConversationViewController: UIViewController {
//
if !conversationCollectionViewHasBeenMovedToBottomOnce {
conversationCollectionViewHasBeenMovedToBottomOnce = true
// contentInset
setConversaitonCollectionViewOriginalContentInset()
if displayedMessagesRange.length > 0 {
conversationCollectionView.scrollToItemAtIndexPath(NSIndexPath(forItem: displayedMessagesRange.length - 1, inSection: 0), atScrollPosition: UICollectionViewScrollPosition.Bottom, animated: false)
}
@@ -969,7 +969,12 @@ extension ConversationViewController: UICollectionViewDataSource, UICollectionVi
}
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
conversationCollectionViewHasBeenMovedToBottomOnce = true
}
// MARK: UIScrollViewDelegate
func scrollViewDidScroll(scrollView: UIScrollView) {
@@ -87,8 +87,20 @@ class ConversationCell: UITableViewCell {
}
}
}
self.chatLabel.text = latestMessage.textContent
switch latestMessage.mediaType {
case MessageMediaType.Audio.rawValue:
self.chatLabel.text = "[声音]"
case MessageMediaType.Video.rawValue:
self.chatLabel.text = "[视频]"
case MessageMediaType.Image.rawValue:
self.chatLabel.text = "[图片]"
case MessageMediaType.Text.rawValue:
self.chatLabel.text = latestMessage.textContent
default:
break
}
self.timeAgoLabel.text = latestMessage.createdAt.timeAgo
} else {