From 91e7a7a4125b9cd70b6debeb6e10f9f279525ba1 Mon Sep 17 00:00:00 2001 From: David Arenas Date: Sun, 13 Feb 2022 13:36:25 +0100 Subject: [PATCH] Adapt some code after rebase --- .../block-library/src/comment-template/edit.js | 14 ++++++++------ .../block-library/src/comment-template/hooks.js | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/block-library/src/comment-template/edit.js b/packages/block-library/src/comment-template/edit.js index e02310c9a338a1..a6d123e9c6d5e2 100644 --- a/packages/block-library/src/comment-template/edit.js +++ b/packages/block-library/src/comment-template/edit.js @@ -1,7 +1,7 @@ /** * WordPress dependencies */ -import { useState, useMemo, memo } from '@wordpress/element'; +import { useState, memo } from '@wordpress/element'; import { useSelect } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; import { @@ -220,6 +220,12 @@ export default function CommentTemplateEdit( { const blockProps = useBlockProps(); const [ activeComment, setActiveComment ] = useState(); + const { commentOrder, threadCommentsDepth, threadComments } = useSelect( + ( select ) => { + const { getSettings } = select( blockEditorStore ); + return getSettings().__experimentalDiscussionSettings; + } + ); const commentQuery = useCommentQueryArgs( { postId, @@ -244,14 +250,10 @@ export default function CommentTemplateEdit( { [ clientId, commentQuery ] ); - const { commentOrder } = useSelect( ( select ) => { - const { getSettings } = select( blockEditorStore ); - return getSettings().__experimentalDiscussionSettings; - } ); order = order || commentOrder; // Generate a tree structure of comment IDs. - const { commentTree } = useCommentTree( + let commentTree = useCommentTree( // Reverse the order of top comments if needed. order === 'desc' && topLevelComments ? [ ...topLevelComments ].reverse() diff --git a/packages/block-library/src/comment-template/hooks.js b/packages/block-library/src/comment-template/hooks.js index 9111f7967428ef..d792887c72e885 100644 --- a/packages/block-library/src/comment-template/hooks.js +++ b/packages/block-library/src/comment-template/hooks.js @@ -147,5 +147,5 @@ export const useCommentTree = ( topLevelComments ) => { [ topLevelComments ] ); - return { commentTree }; + return commentTree; };