-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Jetpack Post: hide post filters if no items are available #8849
Jetpack Post: hide post filters if no items are available #8849
Conversation
b5e2df3
to
f241b6e
Compare
I don't fully understand the situation. The full solution here is to implement post counts, display them, and not render filters if count is zero. When you say post counts are not implemented, do you mean that we don't have the correct data for post counts in jetpack or that we are not displaying it? |
From the issue title ("Jetpack: Investigate why we display Post/Page filters when there are no items available") and issue description, I got the idea that the task assignee should investigate why we display all the filters even though there are no post items under them and then do the same as on WP.com sites (=> don't show "Trashed" if there are no items under it). There was no mention of adding the counts. If the task is to add the post counts, display them and not render filters if count is zero (this part is done in this PR), my apologies, will do that. |
@lamosty the thing is that hiding a filter if there are no posts for it relies on the counts data. Imagine a case where you have 100 posts, and post 99 is trashed. You won't know there is a trashed post from the main posts screen until infinite scroll fetches the 100 posts, so you wouldn't know whether you need to display "Trashed" or not. That is why we look at the post counts, because then we know exactly what post statuses you have before fetching any. The problem is that Jetpack had incorrect post counts data when we implemented all this. So the investigation needs to be:
|
ee895e0
to
bc71d34
Compare
👍 Tested this and the counts for the most part stay in sync pretty well. I did notice a minor one off on drafts, but I think we can let this go through and keep an eye on if counts can drift. |
bc71d34
to
fb77443
Compare
Thanks for the review @gwwar! I tested the drafts counts and it looks pretty solid on my Jetpack testing site: With 9 drafts: After publishing two of the drafts: |
Great! |
Also, I just noticed that draft counts were working even before changes done in this PR, so even if there are errors with them, shouldn't be due to this PR. |
I just tried this out on staging on my site and I am seeing claim I have 223 trashed posts. I have 3. Ping me on Slack if you'd like to check it out :) |
Hah, that's what I meant about post counts being a bit messed up. cc @lezama |
Fixes #8684. Previously, this happened on
/posts
for a Jetpack site: "(Published/draft/scheduled) all show for a Jetpack site, even when it has none of each type of post". I found out that this was intentional and after asking why, I got this reply from @retrofox:However, it seems like the post counts are still not implemented for Jetpack sites. Is it an issue or do we want to merge this anyways?
Note: In the original issue #8684, @gwwar mentioned that this applies for posts and pages. However, even on non-Jetpack site,
/pages
always show all the page filters ("Drafts", "Scheduled", etc), even if there are no items available. That's why this PR concerns only posts and not pages.Testing instructions