From f5321580a3d0276bb0127f03887185b16a7d776b Mon Sep 17 00:00:00 2001 From: Christian Gastrell Date: Mon, 16 Dec 2024 16:06:03 -0300 Subject: [PATCH] use cleaner types --- .../components/ai-image/featured-image.tsx | 20 ++++++++----------- .../components/ai-image/types.ts | 6 ------ 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/featured-image.tsx b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/featured-image.tsx index bb9eed05bad2a..db2589ce386e5 100644 --- a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/featured-image.tsx +++ b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/featured-image.tsx @@ -31,7 +31,7 @@ import { PLACEMENT_MEDIA_SOURCE_DROPDOWN, } from './types'; import type { ImageResponse } from './hooks/use-ai-image'; -import type { SelectState, EditorSelectors, CoreSelectors } from './types'; +import type { EditorSelectors, CoreSelectors } from './types'; const debug = debugFactory( 'jetpack-ai:featured-image' ); @@ -87,19 +87,15 @@ export default function FeaturedImage( { // https://github.com/WordPress/gutenberg/blob/fe4d8cb936df52945c01c1863f7b87b58b7cc69f/packages/edit-post/CHANGELOG.md?plain=1#L19 const toggleEditorPanelOpened = toggleEditorPanelOpenedFromEditor ?? toggleEditorPanelOpenedFromEditPost; - const isEditorPanelOpened = useSelect( - ( select: ( store: keyof SelectState ) => EditorSelectors ) => { - const isOpened = - select( 'core/editor' ).isEditorPanelOpened ?? - select( 'core/edit-post' ).isEditorPanelOpened; - return isOpened; - }, - [] - ); + const isEditorPanelOpened = useSelect( ( select: ( store ) => EditorSelectors ) => { + const isOpened = + select( editorStore ).isEditorPanelOpened ?? select( 'core/edit-post' ).isEditorPanelOpened; + return isOpened; + }, [] ); const currentFeaturedMedia = useSelect( - ( select: ( store: keyof SelectState ) => EditorSelectors & CoreSelectors ) => { - const mediaId = select( 'core/editor' )?.getEditedPostAttribute?.( 'featured_media' ); + ( select: ( store ) => EditorSelectors & CoreSelectors ) => { + const mediaId = select( editorStore )?.getEditedPostAttribute?.( 'featured_media' ); return mediaId ? select( 'core' )?.getMedia?.( mediaId as number ) : null; }, [] diff --git a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/types.ts b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/types.ts index 6e33b519ff75b..77f688f7dd94a 100644 --- a/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/types.ts +++ b/projects/plugins/jetpack/extensions/plugins/ai-assistant-plugin/components/ai-image/types.ts @@ -17,9 +17,3 @@ export interface CoreSelectors { source_url: string; } | null; } - -export interface SelectState { - 'core/editor': EditorSelectors; - 'core/edit-post': EditorSelectors; - core: CoreSelectors; -}