From 7a1a8de71dd67c70d2f89f233cf674d6901258c6 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Tue, 20 Oct 2015 18:11:12 +0800 Subject: [PATCH] do cacheInAdvance with Navi --- Yep/AppDelegate.swift | 17 +++++++++++++++++ .../ConversationsViewController.swift | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/Yep/AppDelegate.swift b/Yep/AppDelegate.swift index 36fd3311..48cb0a7f 100644 --- a/Yep/AppDelegate.swift +++ b/Yep/AppDelegate.swift @@ -12,6 +12,7 @@ import Crashlytics import AVFoundation import RealmSwift import MonkeyKing +import Navi @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { @@ -365,6 +366,22 @@ class AppDelegate: UIResponder, UIApplicationDelegate { // } // } // } + + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0)) { + + guard let realm = try? Realm() else { + return + } + + let conversations = realm.objects(Conversation) + + conversations.forEach { conversation in + if let latestMessage = conversation.messages.last, user = latestMessage.fromFriend { + let userAvatar = UserAvatar(userID: user.userID, avatarStyle: miniAvatarStyle) + AvatarPod.wakeAvatar(userAvatar, completion: { _ ,_ in }) + } + } + } } private func customAppearce() { diff --git a/Yep/ViewControllers/Conversations/ConversationsViewController.swift b/Yep/ViewControllers/Conversations/ConversationsViewController.swift index 370a95e8..24515fee 100644 --- a/Yep/ViewControllers/Conversations/ConversationsViewController.swift +++ b/Yep/ViewControllers/Conversations/ConversationsViewController.swift @@ -8,6 +8,7 @@ import UIKit import RealmSwift +import Navi let YepNotificationCommentAction = "YepNotificationCommentAction" let YepNotificationOKAction = "YepNotificationOKAction" @@ -146,6 +147,12 @@ class ConversationsViewController: UIViewController { // }) // } + for user in normalUsers() { + + let userAvatar = UserAvatar(userID: user.userID, avatarStyle: nanoAvatarStyle) + AvatarPod.wakeAvatar(userAvatar, completion: { _ ,_ in }) + } + // 每个对话的最近 10 条消息(image or thumbnail) guard let realm = try? Realm() else {