Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hiding dashboard cards: fix scroll position #20454

Merged
merged 1 commit into from
May 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor Author

@kean kean Mar 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scroll(_:to:) code was added in the following PR as a workaround. Unfortunately, it breaks the new personalization feature (see the comment).

I tried removing the workaround to see if it's still needed and was not able to reproduce the issue it's supposed to be fixing, so it should be good to merge.

}
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