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

Posts: Remove PostCountsStore Flux store #4875

Closed
wants to merge 3 commits into from

Conversation

aduth
Copy link
Contributor

@aduth aduth commented Apr 19, 2016

This pull request seeks to migrate the remaining single component using PostCountsStore Flux store to use Redux post counts state, <PostsNavigation />.

Testing instructions:

Verify that posts navigation continues to behave as it did previously, with and without Redux state persistence (disable by restarting Calypso with DISABLE_FEATURES=persist-redux make run).

Specifically:

  • Jetpack sites and all sites posts list do not load counts and always display all statuses
  • Post counts update to reflect "Everyone" / "Only Me" selected toggle state
  • When shown as select dropdown due to limited space, ensure items reflect correct count
  • Statuses are hidden when no counts exist, except Published and Drafts
    • This behaves slightly different than master, specifically that we always show the links for published and drafts even while counts are being loaded (master shows an empty <SectionNav />)

Ensure that no remaining references to post counts Flux store remain. I did note a remaining &meta=counts query parameter in the sync handler test data, but this was not easily removed (assumed hash generated by query parameters).

@aduth aduth added Posts [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. Flux State labels Apr 19, 2016
@aduth
Copy link
Contributor Author

aduth commented Apr 19, 2016

Already encountering at least one regression with how we were previously optimistically handling changes to posts in the counts store. Trashing a post in this branch does not increment counts accordingly in the navigation bar. We could explore cherry-picking pieces from #4557 for incrementing counts on the trash (publish, etc) actions.

@mtias
Copy link
Member

mtias commented Apr 20, 2016

@aduth perhaps it's wise to finish moving to state.posts first.

@aduth
Copy link
Contributor Author

aduth commented Apr 20, 2016

perhaps it's wise to finish moving to state.posts first.

Even at that point, if we want to preserve the optimistic updating of post counts, we'll still probably want to explicitly dispatch an action to increment the counts from the trash button callback.

More broadly to this point, #4557 has uncovered some difficult complexities in managing post state in response to changes, which we haven't encountered to this point. Specifically around managing reducer relations between different parts of the tree, which is frowned upon / not obviously possible. So it's not as simple as I'd hoped in adding a handler for post change actions to the counts reducer, since we can't know the previous item's state from that reducer.

@mtias
Copy link
Member

mtias commented Apr 20, 2016

Wonder if we could keep track of local count modifications separately and use them to modify output of selectors getCount = state.counts + state.counts.local. Whenever a new fetch occurs our "dirty" count gets reconciled.

@aduth
Copy link
Contributor Author

aduth commented Apr 21, 2016

Wonder if we could keep track of local count modifications separately and use them to modify output of selectors

I'll need to look again, but there are a few more complications, especially around (a) having two-step trashing for posts and (b) knowing the previous status for a post (not just incrementing count for trashed, but also decrementing count for current/previous status).

@aduth aduth added [Status] In Progress and removed [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. labels Apr 26, 2016
@aduth
Copy link
Contributor Author

aduth commented Jun 28, 2016

We should probably plan to revive this pull request in the near future, seeing as currently we're making duplicate redundant requests for post counts on the post listing screen (drafts list <QueryPosts />, filter counts PostCountsStore posts endpoint meta). Looks like the major blocker was transitioning post counts on actions, which we have something of a solution for as of #6040.

@lancewillett
Copy link
Contributor

Closing as older and possibly abandoned. Feel free to re-open if still valid and in-progress.

@lancewillett lancewillett deleted the update/post-navigation-post-count branch October 4, 2016 17:52
@lancewillett lancewillett added State and removed State labels Feb 6, 2017
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.

3 participants