mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-12-01 01:40:22 +00:00
Update the swiped row on marking read/unread/starred (in iOS timeline) before animating back to position.
This commit is contained in:
1 parent
b3b8650d12
commit
fa244b212e
1 file changed
+20
-17
@@ -26,6 +26,8 @@ final class MainTimelineViewController: UIViewController, UndoableCommandRunner
|
||||
private var feedNameAndDateAboveTitle = false
|
||||
private var showsFullTitles = false
|
||||
private var articleIDsToReload = Set<String>()
|
||||
/// The article whose row was just swiped to change its status.
|
||||
private var swipedArticleID: String?
|
||||
private lazy var feedTapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(showFeedInspector(_:)))
|
||||
private lazy var filterButton = UIBarButtonItem(image: Assets.Images.filter, style: .plain, target: self, action: #selector(toggleFilter(_:)))
|
||||
private lazy var nextUnreadButton = UIBarButtonItem(image: Assets.Images.nextUnread, style: .plain, target: self, action: #selector(nextUnread(_:)))
|
||||
@@ -838,14 +840,8 @@ private extension MainTimelineViewController {
|
||||
NSLocalizedString("Starred", comment: "Starred")
|
||||
UIAccessibility.post(notification: .announcement, argument: announcement)
|
||||
|
||||
/// The call to `toggleStar` is delayed in order to allow
|
||||
/// the swipe animation to complete. Calling `toggleStar` with no
|
||||
/// delay results UICollectionView internal inconsistency: unexpected
|
||||
/// removal of the current swipe occurrence’s mask view error.
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.85) {
|
||||
self?.toggleStar(article)
|
||||
}
|
||||
|
||||
self?.swipedArticleID = article.articleID
|
||||
self?.toggleStar(article)
|
||||
completion(true)
|
||||
}
|
||||
|
||||
@@ -932,13 +928,8 @@ private extension MainTimelineViewController {
|
||||
NSLocalizedString("Marked as Read", comment: "Accessibility announcement")
|
||||
UIAccessibility.post(notification: .announcement, argument: announcement)
|
||||
|
||||
/// The call to `toggleRead` is delayed in order to allow
|
||||
/// the swipe animation to complete. Calling `toggleRead` with no
|
||||
/// delay results UICollectionView internal inconsistency: unexpected
|
||||
/// removal of the current swipe occurrence’s mask view error.
|
||||
DispatchQueue.main.asyncAfter(wallDeadline: .now() + 0.85) {
|
||||
self?.toggleRead(article)
|
||||
}
|
||||
self?.swipedArticleID = article.articleID
|
||||
self?.toggleRead(article)
|
||||
completion(true)
|
||||
}
|
||||
|
||||
@@ -1156,8 +1147,20 @@ private extension MainTimelineViewController {
|
||||
return
|
||||
}
|
||||
|
||||
let visibleArticles = indexPaths.compactMap { dataSource.itemIdentifier(for: $0) }
|
||||
let visibleUpdatedArticles = visibleArticles.filter { articleIDs.contains($0.articleID) }
|
||||
var visibleUpdatedArticles = indexPaths.compactMap { dataSource.itemIdentifier(for: $0) }.filter { articleIDs.contains($0.articleID) }
|
||||
|
||||
// The swiped row is updated in place, since a snapshot reload during the swipe animation triggers a UICollectionView
|
||||
// “unexpected removal of the current swipe occurrence’s mask view” error. A status change doesn’t change a row’s height.
|
||||
if let swipedArticleID, articleIDs.contains(swipedArticleID) {
|
||||
self.swipedArticleID = nil
|
||||
if let index = visibleUpdatedArticles.firstIndex(where: { $0.articleID == swipedArticleID }) {
|
||||
let swipedArticle = visibleUpdatedArticles.remove(at: index)
|
||||
if let indexPath = dataSource.indexPath(for: swipedArticle), let cell = collectionView.cellForItem(at: indexPath) as? MainTimelineCell {
|
||||
cell.cellData = configure(article: swipedArticle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reloadCells(visibleUpdatedArticles)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user