Skip to content

Commit

Permalink
Fix an issue with incorrect scroll position on dashboard after changi…
Browse files Browse the repository at this point in the history
…ng card visibility
  • Loading branch information
kean committed Mar 31, 2023
1 parent 10cc23e commit 5ce2bef
Showing 1 changed file with 1 addition and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,7 @@ private extension BlogDashboardViewModel {

func applySnapshot(for cards: [DashboardCardModel]) {
let snapshot = createSnapshot(from: cards)
let scrollView = viewController?.mySiteScrollView
let position = scrollView?.contentOffset

dataSource?.apply(snapshot, animatingDifferences: false) { [weak self] in
guard let scrollView = scrollView, let position = position else {
return
}

self?.scroll(scrollView, to: position)
}
dataSource?.apply(snapshot, animatingDifferences: false)
}

func createSnapshot(from cards: [DashboardCardModel]) -> DashboardSnapshot {
Expand All @@ -175,12 +166,6 @@ private extension BlogDashboardViewModel {
return snapshot
}

func scroll(_ scrollView: UIScrollView, to position: CGPoint) {
if position.y > 0 {
scrollView.setContentOffset(position, animated: false)
}
}

// In case a draft is saved and the drafts card
// is not appearing, we show it.
@objc func showDraftsCardIfNeeded() {
Expand Down

0 comments on commit 5ce2bef

Please sign in to comment.