Skip to content

Commit

Permalink
Merge pull request wordpress-mobile#20454 from kean/feature/personali…
Browse files Browse the repository at this point in the history
…ze-home-tab-fix-scroll-position

Hiding dashboard cards: fix scroll position
  • Loading branch information
kean authored May 31, 2023
2 parents d6713d8 + 5ce2bef commit 9c58ff9
Showing 1 changed file with 1 addition and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,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 @@ -184,12 +175,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 9c58ff9

Please sign in to comment.