From 939f2f584ee0b61935b2daa1fdfd5773691f56a5 Mon Sep 17 00:00:00 2001 From: karthick-murugan Date: Thu, 5 Dec 2024 11:06:54 +0530 Subject: [PATCH] Feedback updates --- .../src/components/collab-sidebar/comments.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/editor/src/components/collab-sidebar/comments.js b/packages/editor/src/components/collab-sidebar/comments.js index e7895f3a25fde..afd54694f57c7 100644 --- a/packages/editor/src/components/collab-sidebar/comments.js +++ b/packages/editor/src/components/collab-sidebar/comments.js @@ -17,7 +17,7 @@ import { } from '@wordpress/components'; import { Icon, check, published, moreVertical } from '@wordpress/icons'; import { __, _x } from '@wordpress/i18n'; -import { useSelect, useDispatch, select } from '@wordpress/data'; +import { useSelect, useDispatch } from '@wordpress/data'; import { store as blockEditorStore } from '@wordpress/block-editor'; /** @@ -64,13 +64,13 @@ export function Comments( { setIsConfirmDialogOpen( false ); }; + const { getSelectedBlockClientId, getBlock, getBlocks } = + useSelect( blockEditorStore ); + const blockCommentId = useSelect( () => { - const clientID = select( blockEditorStore ).getSelectedBlockClientId(); - return ( - select( blockEditorStore ).getBlock( clientID )?.attributes - ?.blockCommentId ?? false - ); - }, [] ); + const clientID = getSelectedBlockClientId(); + return getBlock( clientID )?.attributes?.blockCommentId ?? false; + } ); const findBlockByCommentId = ( blocks, commentId ) => { for ( const block of blocks ) { @@ -92,7 +92,7 @@ export function Comments( { const { selectBlock } = useDispatch( blockEditorStore ); const handleThreadClick = ( thread ) => { - const selClientBlocks = select( blockEditorStore ).getBlocks(); + const selClientBlocks = getBlocks(); const block = findBlockByCommentId( selClientBlocks, thread.id ); if ( block ) { selectBlock( block.clientId ); // Use the action to select the block