Skip to content
Merged
Changes from 1 commit
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
Next Next commit
Add default avataar in notes in block toolbar
  • Loading branch information
hbhalodia committed Jun 1, 2026
commit 40fe4712af827131e9e65efb7e0bad05b05e1ab0
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import { ToolbarButton } from '@wordpress/components';
import { Stack } from '@wordpress/ui';
import { __, sprintf } from '@wordpress/i18n';
import { useMemo } from '@wordpress/element';
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
import {
privateApis as blockEditorPrivateApis,
store as blockEditorStore,
} from '@wordpress/block-editor';
import { useSelect } from '@wordpress/data';

/**
* Internal dependencies
Expand All @@ -16,6 +20,12 @@ import { getAvatarBorderColor } from './utils';
const { NoteIconToolbarSlotFill } = unlock( blockEditorPrivateApis );

export function NoteAvatarIndicator( { onClick, note } ) {
const defaultAvatar = useSelect( ( select ) => {
const { getSettings } = select( blockEditorStore );
const { __experimentalDiscussionSettings } = getSettings();
return __experimentalDiscussionSettings?.avatarURL;
}, [] );

const threadParticipants = useMemo( () => {
if ( ! note ) {
return [];
Expand All @@ -29,7 +39,7 @@ export function NoteAvatarIndicator( { onClick, note } ) {

allNotes.forEach( ( entry ) => {
// Track thread participants (original author + repliers).
if ( entry.author_name && entry.author_avatar_urls ) {
if ( entry.author_name ) {
Comment thread
hbhalodia marked this conversation as resolved.
Outdated
if ( ! participantsMap.has( entry.author ) ) {
participantsMap.set( entry.author, {
name: entry.author_name,
Expand Down Expand Up @@ -84,7 +94,7 @@ export function NoteAvatarIndicator( { onClick, note } ) {
{ visibleParticipants.map( ( participant ) => (
<img
key={ participant.id }
src={ participant.avatar }
src={ participant.avatar || defaultAvatar }
alt={ participant.name }
className="editor-note-indicator__avatar"
style={ {
Expand Down
Loading