-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Fix entity cache misses for single posts due to string as recordKey #52338
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
Changes from 7 commits
6add642
0fdff62
6397fd6
643cb8b
457ba2d
37560fb
9d70104
7fe8755
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,9 +30,9 @@ import SidebarNavigationScreenDetailsFooter from '../sidebar-navigation-screen-d | |
| export default function SidebarNavigationScreenPage() { | ||
| const navigator = useNavigator(); | ||
| const { setCanvasMode } = unlock( useDispatch( editSiteStore ) ); | ||
| const { | ||
| params: { postId }, | ||
| } = useNavigator(); | ||
| const { params } = useNavigator(); | ||
|
|
||
| const postId = Number( params?.postId ); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As this is Page entities we know it's a number. |
||
| const { record } = useEntityRecord( 'postType', 'page', postId ); | ||
|
|
||
| const { featuredMediaAltText, featuredMediaSourceUrl } = useSelect( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,13 +16,16 @@ import useInitEditedEntityFromURL from '../sync-state-with-url/use-init-edited-e | |
| import usePatternDetails from './use-pattern-details'; | ||
| import { store as editSiteStore } from '../../store'; | ||
| import { unlock } from '../../lock-unlock'; | ||
| import normalizePostIdForPostType from '../../utils/normalize-post-id-for-post-type'; | ||
|
|
||
| export default function SidebarNavigationScreenPattern() { | ||
| const { params } = useNavigator(); | ||
| const { categoryType } = getQueryArgs( window.location.href ); | ||
| const { postType, postId } = params; | ||
| const { setCanvasMode } = unlock( useDispatch( editSiteStore ) ); | ||
|
|
||
| const { params } = useNavigator(); | ||
| const { postType } = params; | ||
| const postId = normalizePostIdForPostType( params?.postId, postType ); | ||
|
||
|
|
||
| useInitEditedEntityFromURL(); | ||
|
|
||
| const patternDetails = usePatternDetails( postType, postId ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| const POST_TYPES_THAT_USE_STRING_BASED_IDS = [ | ||
| 'wp_template', | ||
| 'wp_template_part', | ||
| ]; | ||
|
||
| export default function normalizePostIdForPostType( postId, postType ) { | ||
| return ! POST_TYPES_THAT_USE_STRING_BASED_IDS?.includes( postType ) | ||
| ? Number( postId ) | ||
| : postId; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is definitely Navigation posts we know it's a number.