Skip to content

Fix loading when site model is incomplete#9353

Merged
0nko merged 7 commits intodevelopfrom
feature/fix_loading_when_site_model_is_incomplete
Mar 6, 2019
Merged

Fix loading when site model is incomplete#9353
0nko merged 7 commits intodevelopfrom
feature/fix_loading_when_site_model_is_incomplete

Conversation

@planarvoid
Copy link
Copy Markdown
Contributor

Fixes #9352
This PR introduces a SiteModelProvider, which provides an up-to-date version of the SiteModel and triggers a data refresh, when the SiteModel is updated. I've replaced the SiteModel that was passed around as a parameter all around the use cases with the provider. The only place where we're still retrieving the SiteModel is inside of the StatsFragment where we initialize the SiteModelProvider in the start method of the StatsViewModel.

To test:

  • Create a self-hosted site (jurassic.ninja)
  • Add the self-hosted site in the app
  • Go to stats
  • Install Jetpack and connect it to your account
  • The stats open with the correct data (empty) after the process is finished

@planarvoid planarvoid added this to the 12.0 milestone Mar 1, 2019
@planarvoid planarvoid requested a review from 0nko March 1, 2019 13:51
@peril-wordpress-mobile
Copy link
Copy Markdown

Warnings
⚠️ PR has more than 500 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 dangerJS

Copy link
Copy Markdown
Contributor

@0nko 0nko left a comment

Choose a reason for hiding this comment

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

Looks great. I hope the SiteProvider will be used everywhere, eventually. I've left a couple of comments in the code. Let me know what you think.


@Subscribe(threadMode = ThreadMode.MAIN)
fun onSiteChanged(event: OnSiteChanged) {
val site = siteStore.getSiteByLocalId(siteModel.id)
Copy link
Copy Markdown
Contributor

@0nko 0nko Mar 4, 2019

Choose a reason for hiding this comment

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

This looks a bit cumbersome. When updating the SiteProvider's site value, you must already know what it is :). Would it be possible to update the OnSiteChanged to include the new site value? That way, it wouldn't be necessary to call start(site) and the dispatcher registration could happen in the constructor.

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.

You're totally right and I think it should be done this way. I think it's out of scope for this PR. At least we're containing this logic in one place. I think it might make sense to rename this SiteModelProvider to something like StatsSiteProvider because it shouldn't be used anywhere else right now. I think adding a full reusable SiteModelProvider should be a separate task. Let me know what you think :-)

@planarvoid
Copy link
Copy Markdown
Contributor Author

@0nko This should be ready for another try

Copy link
Copy Markdown
Contributor

@0nko 0nko left a comment

Choose a reason for hiding this comment

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

Thanks for the changes. :shipit:

@0nko 0nko merged commit 6367231 into develop Mar 6, 2019
@0nko 0nko deleted the feature/fix_loading_when_site_model_is_incomplete branch March 6, 2019 09:36
@0nko 0nko self-assigned this Mar 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants