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

Fix fetching Nav fallback ID flushing Navigation entity cache #52069

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions packages/core-data/src/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ export const getBlockPatternCategories =

export const getNavigationFallbackId =
() =>
async ( { dispatch } ) => {
async ( { dispatch, select } ) => {
const fallback = await apiFetch( {
path: addQueryArgs( '/wp-block-editor/v1/navigation-fallback', {
_embed: true,
Expand All @@ -585,7 +585,16 @@ export const getNavigationFallbackId =
dispatch.receiveNavigationFallbackId( fallback?.id );

if ( record ) {
const invalidateNavigationQueries = true;
// If the fallback is already in the store, don't invalidate navigation queries.
// Otherwise, invalidate the cache for the scenario where there were no Navigation
// posts in the state and the fallback created one.
const invalidateNavigationQueries = select.getEntityRecord(
'postType',
'wp_navigation',
fallback?.id
)
? false
: true;
getdave marked this conversation as resolved.
Show resolved Hide resolved
getdave marked this conversation as resolved.
Show resolved Hide resolved

dispatch.receiveEntityRecords(
'postType',
Expand Down