publishpress / PublishPress-Blocks

PublishPress Blocks adds the missing blocks and configuration you need to build professional websites. Take the control of the new Gutenberg editor with user edition profile configuration and 20+ new blocks and options.
15 stars 8 forks source link

Slow content refresh #655

Closed htmgarcia closed 2 years ago

htmgarcia commented 3 years ago

The Content Display takes some time to display the actual content in Appearance > Widgets in WP 5.8 RC-4 This could be an issue introduced by us at some point to make sure when switching the filters for CPT are applied to the preview in regular post editor. Screen Shot 2021-07-16 at 11 19 24

Several seconds later displays the content:

Screen Shot 2021-07-16 at 11 21 49

htmgarcia commented 3 years ago

There is a delay of 5 or 6 seconds before the block start loading. This happens on Appearance > Widgets, but not in post edit. hasPosts value is 0 until changes to false https://github.com/publishpress/PublishPress-Blocks/blob/ppb-655/src/assets/blocks/recent-posts/block.jsx#L836-L837 Screen Shot 2021-07-29 at 15 23 29

@contactashish13 any idea what could be causing this delay?

htmgarcia commented 3 years ago

@contactashish13 when you have a chance, please let me know if you were able to debug this one, please.

contactashish13 commented 3 years ago

@htmgarcia on it today!

contactashish13 commented 3 years ago

@htmgarcia the behavior is slightly different in posts and widgets. It appears that in widgets calling getEntityRecords returns an empty array in widgets but a null in posts. That is why the transition from 0 to false/null to a positive number in widgets but in posts it goes from false/null to a positive number.

Could it because because of cached data? I tried to add a random timestamp parameter custom_pp to recentPostsQuery to burst the cache but that doesn't work either.

in widgets

edit b4 getEntityRecords undefined {order: "desc", orderby: "date", per_page: 8, custom_pp: 1630400474133}
edit after getEntityRecords undefined {order: "desc", orderby: "date", per_page: 8, custom_pp: 1630400474133} []

in posts

edit b4 getEntityRecords undefined {order: "desc", orderby: "date", per_page: 8, custom_pp: 1630400517659}
edit after getEntityRecords undefined {order: "desc", orderby: "date", per_page: 8, custom_pp: 1630400517659} null

with the below code change

console.log('edit b4 getEntityRecords', postType, recentPostsQuery);
let x = getEntityRecords( 'postType', postType ? postType : 'post', recentPostsQuery );
console.log('edit after getEntityRecords', postType, recentPostsQuery, x);
htmgarcia commented 3 years ago

@contactashish13 tweaking the code to detect when the block is in widget area or post edit. Would that help?

contactashish13 commented 3 years ago

@htmgarcia yeah that was my first thought too but I couldn't find anything elegant that would allow that. I can always check if I'm inside the widget DOM but that seemed like a hack to me. Let me know if you have a better idea.

htmgarcia commented 2 years ago

Fixed with #800 and possibly in combination with #797