Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions packages/editor/src/components/collab-sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export default function CollabSidebar() {
} );

// Process comments to build the tree structure
const { resultComments, sortedThreads } = useMemo( () => {
const { resultComments, unresolvedSortedThreads } = useMemo( () => {
// Create a compare to store the references to all objects by id
const compare = {};
const result = [];
Expand All @@ -291,7 +291,7 @@ export default function CollabSidebar() {
} );

if ( 0 === result?.length ) {
return { resultComments: [], sortedThreads: [] };
return { resultComments: [], unresolvedSortedThreads: [] };
}

const updatedResult = result.map( ( item ) => ( {
Expand All @@ -305,11 +305,18 @@ export default function CollabSidebar() {
updatedResult.map( ( thread ) => [ thread.id, thread ] )
);

const sortedComments = blockCommentIds
// Get comments by block order, filter out undefined threads, and exclude resolved comments.
const unresolvedSortedComments = blockCommentIds
.map( ( id ) => threadIdMap.get( id ) )
.filter( ( thread ) => thread !== undefined );
.filter(
( thread ) =>
thread !== undefined && thread.status !== 'approved'
);

return { resultComments: updatedResult, sortedThreads: sortedComments };
return {
resultComments: updatedResult,
unresolvedSortedThreads: unresolvedSortedComments,
};
}, [ threads, blocks ] );

// Get the global styles to set the background color of the sidebar.
Expand Down Expand Up @@ -358,7 +365,7 @@ export default function CollabSidebar() {
headerClassName="editor-collab-sidebar__header"
>
<CollabSidebarContent
comments={ sortedThreads }
comments={ unresolvedSortedThreads }
showCommentBoard={ showCommentBoard }
setShowCommentBoard={ setShowCommentBoard }
styles={ {
Expand Down
Loading