mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-20 18:26:34 +10:00
Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user