mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-10 21:36:49 +10:00
Use reloaddata
This commit is contained in:
@@ -198,26 +198,27 @@ class FeedsViewController: UIViewController {
|
||||
|
||||
if let strongSelf = self {
|
||||
|
||||
let oldFeedSet = Set(strongSelf.feeds)
|
||||
let newFeedSet = Set(feeds)
|
||||
// let oldFeedSet = Set(strongSelf.feeds)
|
||||
// let newFeedSet = Set(feeds)
|
||||
|
||||
let unionFeedSet = oldFeedSet.union(newFeedSet)
|
||||
let allNewFeedSet = newFeedSet.subtract(oldFeedSet)
|
||||
// let unionFeedSet = oldFeedSet.union(newFeedSet)
|
||||
// let allNewFeedSet = newFeedSet.subtract(oldFeedSet)
|
||||
|
||||
let allFeeds = Array(unionFeedSet).sort({ $0.createdUnixTime > $1.createdUnixTime })
|
||||
|
||||
let newIndexPaths = allNewFeedSet.map({ allFeeds.indexOf($0) }).flatMap({ $0 }).map({ NSIndexPath(forRow: $0, inSection: Section.Feed.rawValue) })
|
||||
// let allFeeds = Array(unionFeedSet)
|
||||
//
|
||||
// let newIndexPaths = allNewFeedSet.map({ allFeeds.indexOf($0) }).flatMap({ $0 }).map({ NSIndexPath(forRow: $0, inSection: Section.Feed.rawValue) })
|
||||
|
||||
dispatch_async(dispatch_get_main_queue()) {
|
||||
|
||||
strongSelf.feeds = allFeeds
|
||||
|
||||
if newIndexPaths.count == allNewFeedSet.count {
|
||||
strongSelf.updateFeedsTableViewOrInsertWithIndexPaths(newIndexPaths)
|
||||
|
||||
} else {
|
||||
strongSelf.updateFeedsTableViewOrInsertWithIndexPaths(nil)
|
||||
}
|
||||
strongSelf.feeds = feeds
|
||||
strongSelf.feedsTableView.reloadData()
|
||||
|
||||
// if newIndexPaths.count == allNewFeedSet.count {
|
||||
// strongSelf.updateFeedsTableViewOrInsertWithIndexPaths(newIndexPaths)
|
||||
//
|
||||
// } else {
|
||||
// strongSelf.updateFeedsTableViewOrInsertWithIndexPaths(nil)
|
||||
// }
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user