Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Remove custom gravatar resolver
  • Loading branch information
maxschmeling committed Feb 17, 2026
commit 0ba21ed14570950359d35a0da34f8686720342ea
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Extracts the best available avatar URL from a collaborator's avatar_urls map.
* Prefers the 48px size, then 96px, then 24px.
*
* @param avatarUrls - The avatar_urls map from collaborator info.
*/
export function getAvatarUrl( avatarUrls?: {
'24'?: string;
'48'?: string;
'96'?: string;
} ): string | undefined {
return avatarUrls?.[ '48' ] || avatarUrls?.[ '96' ] || avatarUrls?.[ '24' ];
}
106 changes: 0 additions & 106 deletions packages/editor/src/components/collaborators-overlay/gravatar-check.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ import {
type SelectionCursor,
SelectionType,
} from '@wordpress/core-data';
import { useEffect, useMemo, useRef, useState } from '@wordpress/element';
import { useEffect, useMemo, useState } from '@wordpress/element';

import { unlock } from '../../lock-unlock';
import { getAvatarUrl, resolveGravatarUrl } from './gravatar-check';
import { useResolveGravatars } from './use-resolve-gravatars';
import { getAvatarUrl } from './get-avatar-url';
import { getAvatarBorderColor } from '../collab-sidebar/utils';

const { useActiveCollaborators, useGetAbsolutePositionIndex } =
Expand Down Expand Up @@ -51,19 +50,6 @@ export function useRenderCursors(
[]
);

// Initiate gravatar default-detection for all remote users so the Avatar
// component can show initials when no custom gravatar exists.
const avatarUrls = useMemo(
() =>
sortedUsers
.filter( ( user: any ) => ! user.isMe )
.map( ( user: any ) =>
getAvatarUrl( user.collaboratorInfo.avatar_urls )
),
[ sortedUsers ]
);
const gravatarVersion = useResolveGravatars( avatarUrls );

const computeCursors = useMemo(
() => () => {
if ( ! overlayElement || ! blockEditorDocument ) {
Expand All @@ -84,8 +70,8 @@ export function useRenderCursors(
const userName = user.collaboratorInfo.name;
const clientId = user.clientId;
const color = getAvatarBorderColor( user.collaboratorInfo.id );
const avatarUrl = resolveGravatarUrl(
getAvatarUrl( user.collaboratorInfo.avatar_urls )
const avatarUrl = getAvatarUrl(
user.collaboratorInfo.avatar_urls
);

let coords: {
Expand Down Expand Up @@ -158,14 +144,6 @@ export function useRenderCursors(

useEffect( computeCursors, [ computeCursors ] );

// Recompute cursors when gravatar checks complete so resolved avatar
// URLs replace default placeholders with the component's initials fallback.
const computeCursorsRef = useRef( computeCursors );
computeCursorsRef.current = computeCursors;
useEffect( () => {
computeCursorsRef.current();
}, [ gravatarVersion ] );

const rerenderCursorsAfterDelay = useMemo(
() => () => {
const timeout = setTimeout( computeCursors, 500 );
Expand Down

This file was deleted.

27 changes: 5 additions & 22 deletions packages/editor/src/components/collaborators-presence/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
Button,
privateApis as componentsPrivateApis,
} from '@wordpress/components';
import { useMemo, useState } from '@wordpress/element';
import { useState } from '@wordpress/element';
import {
privateApis,
type PostEditorAwarenessState,
Expand All @@ -11,11 +11,7 @@ import { __, sprintf } from '@wordpress/i18n';

import { CollaboratorsList } from './list';
import { unlock } from '../../lock-unlock';
import {
getAvatarUrl,
resolveGravatarUrl,
} from '../collaborators-overlay/gravatar-check';
import { useResolveGravatars } from '../collaborators-overlay/use-resolve-gravatars';
import { getAvatarUrl } from '../collaborators-overlay/get-avatar-url';
import { getAvatarBorderColor } from '../collab-sidebar/utils';

import './styles/collaborators-presence.scss';
Expand Down Expand Up @@ -51,17 +47,6 @@ export function CollaboratorsPresence( {
( collaborator ) => ! collaborator.isMe
);

// Initiate gravatar default-detection so the Avatar component can show
// initials when no custom gravatar exists.
const collaboratorAvatarUrls = useMemo(
() =>
otherActiveCollaborators.map( ( c ) =>
getAvatarUrl( c.collaboratorInfo.avatar_urls )
),
[ otherActiveCollaborators ]
);
useResolveGravatars( collaboratorAvatarUrls );

const [ isPopoverVisible, setIsPopoverVisible ] = useState( false );
const [ popoverAnchor, setPopoverAnchor ] = useState< HTMLElement | null >(
null
Expand Down Expand Up @@ -94,11 +79,9 @@ export function CollaboratorsPresence( {
( collaboratorState ) => (
<Avatar
key={ collaboratorState.clientId }
src={ resolveGravatarUrl(
getAvatarUrl(
collaboratorState.collaboratorInfo
.avatar_urls
)
src={ getAvatarUrl(
collaboratorState.collaboratorInfo
.avatar_urls
) }
name={
collaboratorState.collaboratorInfo.name
Expand Down
13 changes: 4 additions & 9 deletions packages/editor/src/components/collaborators-presence/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import { close } from '@wordpress/icons';
import { type PostEditorAwarenessState } from '@wordpress/core-data';

import { unlock } from '../../lock-unlock';
import {
getAvatarUrl,
resolveGravatarUrl,
} from '../collaborators-overlay/gravatar-check';
import { getAvatarUrl } from '../collaborators-overlay/get-avatar-url';
import { getAvatarBorderColor } from '../collab-sidebar/utils';

import './styles/collaborators-list.scss';
Expand Down Expand Up @@ -74,11 +71,9 @@ export function CollaboratorsList( {
} }
>
<Avatar
src={ resolveGravatarUrl(
getAvatarUrl(
collaboratorState.collaboratorInfo
.avatar_urls
)
src={ getAvatarUrl(
collaboratorState.collaboratorInfo
.avatar_urls
) }
name={ collaboratorState.collaboratorInfo.name }
borderColor={ getAvatarBorderColor(
Expand Down
Loading