From a7dbaa73d63554a41035d578f8bb112674bb5a85 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Fri, 16 Feb 2024 08:23:01 +0400 Subject: [PATCH] Navigation: Avoid using embedded records from fallback API (#59076) Co-authored-by: Mamaduka Co-authored-by: youknowriad --- packages/core-data/src/resolvers.js | 34 ++--------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/packages/core-data/src/resolvers.js b/packages/core-data/src/resolvers.js index 7f4d3f54776d4..f59520f3c436b 100644 --- a/packages/core-data/src/resolvers.js +++ b/packages/core-data/src/resolvers.js @@ -661,42 +661,12 @@ export const getUserPatternCategories = export const getNavigationFallbackId = () => - async ( { dispatch, select } ) => { + async ( { dispatch } ) => { const fallback = await apiFetch( { - path: addQueryArgs( '/wp-block-editor/v1/navigation-fallback', { - _embed: true, - } ), + path: addQueryArgs( '/wp-block-editor/v1/navigation-fallback' ), } ); - const record = fallback?._embedded?.self; - dispatch.receiveNavigationFallbackId( fallback?.id ); - - if ( record ) { - // 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 existingFallbackEntityRecord = select.getEntityRecord( - 'postType', - 'wp_navigation', - fallback?.id - ); - const invalidateNavigationQueries = ! existingFallbackEntityRecord; - dispatch.receiveEntityRecords( - 'postType', - 'wp_navigation', - record, - undefined, - invalidateNavigationQueries - ); - - // Resolve to avoid further network requests. - dispatch.finishResolution( 'getEntityRecord', [ - 'postType', - 'wp_navigation', - fallback?.id, - ] ); - } }; export const getDefaultTemplateId =