Skip to content

Commit

Permalink
Merge pull request #93 from rishishah-multidots/try/inline-block-comm…
Browse files Browse the repository at this point in the history
…enting

fix lint error
poojabhimani12 authored Oct 23, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents a342e27 + ae50d7a commit 2ca51c3
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions packages/editor/src/components/collab-sidebar/index.js
Original file line number Diff line number Diff line change
@@ -96,6 +96,35 @@ export default function CollabSidebar() {
// Get the dispatch functions to save the comment and update the block attributes.
const { updateBlockAttributes } = useDispatch( blockEditorStore );

// Process comments to build the tree structure
const resultComments = useMemo( () => {
// Create a compare to store the references to all objects by id
const compare = {};
const result = [];

const filteredComments = threads.filter(
( comment ) => comment.status !== 'trash'
);

// Initialize each object with an empty `reply` array
filteredComments.forEach( ( item ) => {
compare[ item.id ] = { ...item, reply: [] };
} );

// Iterate over the data to build the tree structure
filteredComments.forEach( ( item ) => {
if ( item.parent === 0 ) {
// If parent is 0, it's a root item, push it to the result array
result.push( compare[ item.id ] );
} else if ( compare[ item.parent ] ) {
// Otherwise, find its parent and push it to the parent's `reply` array
compare[ item.parent ].reply.push( compare[ item.id ] );
}
} );

return result;
}, [ threads ] );

const openCollabBoard = () => {
setShowCommentBoard( true );
enableComplementaryArea( 'core', 'edit-post/collab-sidebar' );
@@ -234,35 +263,6 @@ export default function CollabSidebar() {
return null; // or maybe return some message indicating no threads are available.
}

// Process comments to build the tree structure
const resultComments = useMemo( () => {
// Create a compare to store the references to all objects by id
const compare = {};
const result = [];

const filteredComments = threads.filter(
( comment ) => comment.status !== 'trash'
);

// Initialize each object with an empty `reply` array
filteredComments.forEach( ( item ) => {
compare[ item.id ] = { ...item, reply: [] };
} );

// Iterate over the data to build the tree structure
filteredComments.forEach( ( item ) => {
if ( item.parent === 0 ) {
// If parent is 0, it's a root item, push it to the result array
result.push( compare[ item.id ] );
} else if ( compare[ item.parent ] ) {
// Otherwise, find its parent and push it to the parent's `reply` array
compare[ item.parent ].reply.push( compare[ item.id ] );
}
} );

return result;
}, [ threads ] );

return (
<>
{ ! blockCommentID && (

0 comments on commit 2ca51c3

Please sign in to comment.