Skip to content

My Site Dashboard: Refactor dashboard's data source - #18310

Merged
hassaanelgarem merged 15 commits into
feature/dashboard-arch-refactor/basefrom
feature/dashboard-arch-refactor/snapshot-logic
Apr 11, 2022
Merged

My Site Dashboard: Refactor dashboard's data source #18310
hassaanelgarem merged 15 commits into
feature/dashboard-arch-refactor/basefrom
feature/dashboard-arch-refactor/snapshot-logic

Conversation

@hassaanelgarem

Copy link
Copy Markdown
Contributor

Part of #18308

Description

  • Decouples remote cards from DashboardCard enum
  • Adds cards for each type of posts cell
  • Implements shouldShow logic for all cards. Borrows posts cards logic from DashboardPostsCardCell
  • The dashboard service fetch functions now return an array of card models, instead of a snapshot. And the array contains an element for each card to be shown (multiple posts cards)
  • The dashboard view model is now responsible for creating the snapshot from the aforementioned array.
  • Modified BlogDashboardRemoteEntity to be hashable and used it to hash DashboardCardModel instead of the dictionary.

Testing Instructions

This PR introduces weird behavior in the dashboard. Because of the refactor, the same cards are shown multiple times. However, the first ones are empty due to the VC dequeue logic implemented. This will be fixed in a future PR.
Again, I would recommend holding off testing till the whole refactor is complete. By then we will have to test that everything behaves the same way it used to do.

Regression Notes

  1. Potential unintended areas of impact
    N/A

  2. What I did to test those areas of impact (or what existing automated tests I relied on)
    N/A

  3. What automated tests I added (or what prevented me from doing so)
    Will add unit tests in another PR.

PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@wpmobilebot

wpmobilebot commented Apr 7, 2022

Copy link
Copy Markdown
Contributor
You can test the changes in Jetpack from this Pull Request by:
  • Clicking here or scanning the QR code below
  • Then installing the build number pr18310-eb76b02 from App Center on your iPhone

The .ipa file can also be downloaded directly here.
If you need access to App Center, please ask a maintainer to add you.

@wpmobilebot

wpmobilebot commented Apr 7, 2022

Copy link
Copy Markdown
Contributor
You can test the changes in WordPress from this Pull Request by:
  • Clicking here or scanning the QR code below
  • Then installing the build number pr18310-eb76b02 from App Center on your iPhone

The .ipa file can also be downloaded directly here.
If you need access to App Center, please ask a maintainer to add you.

enum DashboardCard: String, CaseIterable {
case quickStart
case prompts
case todaysStats = "todays_stats"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need the "todays_stats" here?

@hassaanelgarem hassaanelgarem Apr 10, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@leandroalonso This raw value is currently only used for analytics events. And since I'm not sure when this will be released, I didn't want to have any differences between our events before and after this is released. That's why I left this.
What do you think though? Do you think it's unnecessary?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh got it, let's def not change analytics values. If we remove it we need to refactor the track to keep the same value as before. If it's easier to just leave that here, let's just leave it.

}

func createSnapshot(from cards: [DashboardCardModel]) -> DashboardSnapshot {
let items = cards.map {DashboardItem.cards($0)}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[nit]

Suggested change
let items = cards.map {DashboardItem.cards($0)}
let items = cards.map { DashboardItem.cards($0) }
Suggested change
let items = cards.map {DashboardItem.cards($0)}
let items = cards.map {DashboardItem.cards($0)}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in dcf939a

})
let ghostCellsCount = ghostCells?.count ?? 0
return ghostCellsCount > 0
return currentCards.contains(where: {$0.cardType == .ghost})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Again, you can delete that. Sorry for leaving that and causing you some trouble! 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed in 9990acc 👍

@leandroalonso

Copy link
Copy Markdown
Contributor

Apparently, it wasn't just our posts cards that are duplicated, Github got inspired by it.

@hassaanelgarem

Copy link
Copy Markdown
Contributor Author

Apparently, it wasn't just our posts cards that are duplicated, Github got inspired by it.

That's some next level AI 😄

Base automatically changed from feature/dashboard-arch-refactor/reduce-sections to feature/dashboard-arch-refactor/base April 11, 2022 11:57

@momo-ozawa momo-ozawa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for refactoring! Looking good!


let section = NSCollectionLayoutSection(group: group)
let isQuickActionSection = viewModel.dashboardItem(for: sectionIndex) == .quickActions
let isQuickActionSection = viewModel.isQuickActionsSection(sectionIndex)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@hassaanelgarem
hassaanelgarem merged commit 039f4ee into feature/dashboard-arch-refactor/base Apr 11, 2022
@hassaanelgarem
hassaanelgarem deleted the feature/dashboard-arch-refactor/snapshot-logic branch April 11, 2022 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants