mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-25 20:56:45 +10:00
make sure needReloadData after updateFeeds
This commit is contained in:
@@ -40,7 +40,7 @@ class ImageCache {
|
||||
let attachmentOriginKey = "attachment-0.0-0.0-\(attachmentURL.absoluteString)"
|
||||
|
||||
let attachmentSizeKey = "attachment-\(cacheSize.width)-\(cacheSize.height)-\(attachmentURL.absoluteString)"
|
||||
|
||||
|
||||
let OptionsInfos: KingfisherManager.Options = (forceRefresh: false, lowPriority: false, cacheMemoryOnly: false, shouldDecode: false, queue: cacheAttachmentQueue, scale: UIScreen.mainScreen().scale)
|
||||
//查找当前 Size 的 Cache
|
||||
|
||||
@@ -49,8 +49,6 @@ class ImageCache {
|
||||
if let image = image?.decodedImage() {
|
||||
dispatch_async(dispatch_get_main_queue()) {
|
||||
completion(url: attachmentURL, image: image, cacheType: type)
|
||||
|
||||
Kingfisher.ImageCache.defaultCache.storeImage(image, forKey: attachmentSizeKey, toDisk: false, completionHandler: nil)
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
@@ -439,6 +439,12 @@ class FeedsViewController: BaseViewController {
|
||||
|
||||
if let strongSelf = self {
|
||||
|
||||
let newFeeds = feeds
|
||||
|
||||
var needReloadData = false
|
||||
|
||||
needReloadData = strongSelf.feeds.isEmpty
|
||||
|
||||
if isLoadMore {
|
||||
strongSelf.feeds += feeds
|
||||
|
||||
@@ -446,10 +452,30 @@ class FeedsViewController: BaseViewController {
|
||||
strongSelf.feeds = feeds
|
||||
}
|
||||
|
||||
// 确保有新的才 reload
|
||||
if !feeds.isEmpty {
|
||||
if newFeeds.count == strongSelf.feeds.count {
|
||||
|
||||
var index = 0
|
||||
while index < newFeeds.count {
|
||||
let newFeed = newFeeds[index]
|
||||
let oldFeed = strongSelf.feeds[index]
|
||||
|
||||
if newFeed.id != oldFeed.id {
|
||||
needReloadData = true
|
||||
break
|
||||
}
|
||||
|
||||
index += 1
|
||||
}
|
||||
|
||||
} else {
|
||||
needReloadData = true
|
||||
}
|
||||
}
|
||||
|
||||
if needReloadData {
|
||||
println("new feeds, reloadData")
|
||||
strongSelf.feedsTableView.reloadData() // 服务端有新的排序算法,以及避免刷新后消息数字更新不及时的问题
|
||||
strongSelf.feedsTableView.reloadData()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user