Allow changing/editing PMP on messages

This commit is contained in:
Josie committed 2026-08-03 16:34:20 +01:00
1 parent f3f71642aa
commit bf287072e2
6 files changed
+403 -174

No files matched your search

@@ -0,0 +1,5 @@
---
default: minor
---
# Allow changing/editing PMP on messages
+86 -2
View File
@@ -1,4 +1,9 @@
import type { RoomPinnedEventsEventContent, StateEvents } from '$types/matrix-sdk';
import type {
MatrixClient,
RoomMessageEventContent,
RoomPinnedEventsEventContent,
StateEvents,
} from '$types/matrix-sdk';
import { type Room, type MatrixEvent, type Relations, EventType } from '$types/matrix-sdk';
import {
canEditEvent,
@@ -48,7 +53,7 @@ import { useRoomPinnedEvents } from '$hooks/useRoomPinnedEvents';
import { EmojiBoard } from '$components/emoji-board';
import { MemoizedBody, type ReactionHandler } from '$features/room/message';
import { useRecentEmoji } from '$hooks/useRecentEmoji';
import { BookmarkIcon } from '@phosphor-icons/react';
import { BookmarkIcon, UserIcon } from '@phosphor-icons/react';
import {
computeBookmarkId,
createBookmarkItem,
@@ -61,6 +66,11 @@ import { MATRIX_SABLE_UNSTABLE_FAVORITE_GIFS } from '$unstable/prefixes';
import { useFavoriteGifs } from '$hooks/useFavoriteGifs';
import type { IImageInfo } from '$types/matrix/common';
import { getIncomingMediaMxcUrl } from '../MsgTypeRenderers';
import { TemporaryPersonaPicker } from '$features/room/persona-picker/PersonaPicker';
import { type PerMessageProfile } from '$hooks/usePerMessageProfile';
import { buildReplacementPmpContent } from '$features/room/buildReplacementContent';
import { settingsAtom } from '$state/settings';
import { useSetting } from '$state/hooks/settings';
function WrappedMessage({
isModal,
@@ -390,6 +400,40 @@ function OptionsEmojiBoard({
);
}
type OptionsReproxyPersonaPickerProps = {
mx: MatrixClient;
mEvent: MatrixEvent;
roomId: string;
closeMenu: () => void;
anchor: RectCords;
};
function OptionsReproxyPersonaPicker({
mx,
mEvent,
roomId,
closeMenu,
anchor,
}: OptionsReproxyPersonaPickerProps) {
const reproxyMessage = async (profile: PerMessageProfile | undefined) => {
const content = buildReplacementPmpContent(mEvent.getContent(), mEvent.getId()!, profile);
await mx.sendMessage(roomId, content as RoomMessageEventContent);
closeMenu();
};
return (
<>
<TemporaryPersonaPicker
mx={mx}
hideTabs={true}
onPersonaSelect={reproxyMessage}
requestClose={closeMenu}
anchor={anchor}
/>
</>
);
}
export function OptionQuickMenu({
mEvent,
room,
@@ -399,6 +443,7 @@ export function OptionQuickMenu({
relations,
onReplyClick,
onEditId,
onReproxyId,
hideReadReceipts,
showDeveloperTools,
canPinEvent,
@@ -505,6 +550,7 @@ export function OptionQuickMenu({
relations={relations}
onReplyClick={onReplyClick}
onEditId={onEditId}
onReproxyId={onReproxyId}
hideReadReceipts={hideReadReceipts}
showDeveloperTools={showDeveloperTools}
canPinEvent={canPinEvent}
@@ -546,6 +592,7 @@ export type OptionMenuProps = {
startThread?: boolean
) => void;
onEditId?: (eventId?: string) => void;
onReproxyId?: (profileId?: string) => void;
hideReadReceipts?: boolean;
showDeveloperTools?: boolean;
canPinEvent?: boolean;
@@ -593,6 +640,7 @@ function OptionMenu({
evtTimeline &&
getEventEdits(evtTimeline.getTimelineSet(), evtId, mEvent.getType())?.getRelations();
const isEdited = !!edits?.length;
const [showPersonaSetting] = useSetting(settingsAtom, 'showPersonaSetting');
const onTotalClose = () => {
setModal(null);
@@ -606,6 +654,20 @@ function OptionMenu({
const [emojiBoardAnchor, setEmojiBoardAnchor] = useState<RectCords>();
const [reproxyPickerAnchor, setReproxyPickerAnchor] = useState<RectCords>();
const handleOpenReproxyPicker: MouseEventHandler<HTMLButtonElement> = (evt) => {
const target = isModal
? { x: 0, y: innerHeight, width: 0, height: 0 }
: (evt.currentTarget.parentElement?.parentElement?.getBoundingClientRect() ?? {
x: 0,
y: 0,
width: 0,
height: 0,
});
setReproxyPickerAnchor(target);
};
const handleOpenEmojiBoard: MouseEventHandler<HTMLButtonElement> = (evt) => {
// THIS MAGIC NUMBER SHOULD BE FIXED WHEN SOMEONE FIGURES OUT WHY THE LACK OF IT CREATES A GAP IN THE EMOJIBOARD
const target = isModal
@@ -634,6 +696,15 @@ function OptionMenu({
ActualMessage={<WrappedMessage isModal={isModal} ActualMessage={ActualMessage} />}
/>
)}
{reproxyPickerAnchor !== undefined && (
<OptionsReproxyPersonaPicker
mx={mx}
roomId={room.roomId}
mEvent={mEvent}
closeMenu={onTotalClose}
anchor={reproxyPickerAnchor}
/>
)}
<FocusTrap
focusTrapOptions={{
initialFocus: false,
@@ -779,6 +850,19 @@ function OptionMenu({
</Text>
</MenuItem>
)}
{canEditEvent(mx, mEvent) && showPersonaSetting && (
<MenuItem
size="300"
after={menuIcon(UserIcon)}
radii="300"
data-event-id={mEvent.getId()}
onClick={handleOpenReproxyPicker}
>
<Text className={css.MessageMenuItemText} as="span" size="T300" truncate>
Change Persona
</Text>
</MenuItem>
)}
{!hideReadReceipts && (
<MessageReadReceiptItem
room={room}
+2 -2
View File
@@ -216,7 +216,7 @@ import { AudioMessageRecorder } from './AudioMessageRecorder';
import * as prefix from '$unstable/prefixes';
import { PollDialog } from './poll-modals';
import { useClientConfig } from '$hooks/useClientConfig';
import { PersonaPicker, type PersonaPickerTab } from './persona-picker/PersonaPicker.tsx';
import { PersistentPersonaPicker, type PersonaPickerTab } from './persona-picker/PersonaPicker.tsx';
const LocationDialog = lazy(() =>
import('./location-modal').then((module) => ({ default: module.LocationDialog }))
@@ -2194,7 +2194,7 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
</>
)}
{pmpPickerEnable && (
<PersonaPicker
<PersistentPersonaPicker
tab={personaPickerTab}
mx={mx}
roomId={roomId}
@@ -2,6 +2,9 @@ import type { IContent, IMentions } from '$types/matrix-sdk';
import { MsgType, RelationType } from '$types/matrix-sdk';
import { customHtmlEqualsPlainText } from '$components/editor';
import { sanitizeText } from '$utils/sanitize';
import type { PerMessageProfile } from '$hooks/usePerMessageProfile';
import { convertPerMessageProfileToBeeperFormat } from '$hooks/usePerMessageProfile';
import { MATRIX_UNSTABLE_PER_MESSAGE_PROFILE_PROPERTY_NAME } from '$unstable/prefixes';
/**
* Unified from RoomInput and MessageEditor, which had drifted: this keeps
@@ -92,3 +95,57 @@ export function buildReplacementContent(
return content;
}
// Replacing only the PMP in a content. No, you can't use the above function. I tried.
export function buildReplacementPmpContent(
oldContent: IContent,
eventId: string,
newProfile: PerMessageProfile | undefined
) {
const profileBeeperFormat =
newProfile && convertPerMessageProfileToBeeperFormat(newProfile, true);
// handle fallbacks
if (oldContent[MATRIX_UNSTABLE_PER_MESSAGE_PROFILE_PROPERTY_NAME]) {
const plainBody = oldContent.body;
let newPlainBody = plainBody?.replace(/^.*?: /, '');
const formattedBody = oldContent.formatted_body;
let newFormattedBody = formattedBody?.replace(
/^<strong\s+data-mx-profile-fallback[^>]*>.*?<\/strong>/,
''
);
oldContent.formatted_body = newFormattedBody;
oldContent.body = newPlainBody;
}
if (newProfile) {
const escapedName = sanitizeText(newProfile.name);
const htmlPrefix = `<strong data-mx-profile-fallback>${escapedName}: </strong>`;
if (oldContent.formatted_body) {
oldContent.formatted_body = htmlPrefix + oldContent.formatted_body;
} else {
// we don't have a formatted body, but we need one
oldContent.format = 'org.matrix.custom.html';
const escapedBody = sanitizeText(oldContent.body).replaceAll('\n', '<br/>');
oldContent.formatted_body = `${htmlPrefix}${escapedBody}`;
}
const pmpPrefix = `${newProfile.name}: `;
oldContent.body = pmpPrefix + oldContent.body;
}
const newContent = {
...oldContent,
[MATRIX_UNSTABLE_PER_MESSAGE_PROFILE_PROPERTY_NAME]: profileBeeperFormat,
};
const content: IContent = {
...newContent,
'm.new_content': newContent,
'm.relates_to': { event_id: eventId, rel_type: RelationType.Replace },
};
return content;
}
@@ -111,6 +111,7 @@ export type MessageProps = {
startThread?: boolean
) => void;
onEditId?: (eventId?: string) => void;
onReproxyId?: (eventId?: string) => void;
onReactionToggle: (targetEventId: string, key: string, shortcode?: string) => void;
reply?: ReactNode;
reactions?: ReactNode;
@@ -340,6 +341,7 @@ function MessageInternal(
onReplyClick,
onReactionToggle,
onEditId,
onReproxyId,
reply,
reactions,
hideReadReceipts,
@@ -980,6 +982,7 @@ function MessageInternal(
relations={relations}
onReplyClick={onReplyClick}
onEditId={onEditId}
onReproxyId={onReproxyId}
hideReadReceipts={hideReadReceipts}
showDeveloperTools={showDeveloperTools}
canPinEvent={canPinEvent}
@@ -36,13 +36,17 @@ import type { MatrixClient } from 'matrix-js-sdk';
import { useCallback, useEffect, useRef, useState, type FormEvent } from 'react';
import * as css from './PersonaPicker.css.ts';
import { InfoCard } from '$components/info-card/InfoCard.tsx';
import { InfoIcon } from '@phosphor-icons/react';
import { InfoIcon, XIcon } from '@phosphor-icons/react';
import { ThemeKind, useActiveTheme } from '$hooks/useTheme.ts';
const pillStyles = {
cursor: 'pointer',
} as const;
export enum PersonaPickerPresentation {
TemporarySelectorMenu = 'TemporarySelectorMenu',
PersistentPicker = 'PersistentPicker',
}
export enum PersonaPickerTab {
Global = 'Global',
PerRoom = 'PerRoom',
@@ -51,23 +55,82 @@ export enum PersonaPickerTab {
type PersonaPickerProps = {
tab?: PersonaPickerTab;
mx: MatrixClient;
roomId: string;
suppressEditorRefocus: () => void;
onTabChange: (tab: PersonaPickerTab) => void;
latchedPersona: PerMessageProfile | undefined;
roomId?: string;
suppressEditorRefocus?: () => void;
onTabChange?: (tab: PersonaPickerTab) => void;
latchedPersona?: PerMessageProfile;
hideTabs?: boolean;
onPersonaSelect?: (persona: PerMessageProfile | undefined) => void;
requestClose?: () => void;
showNoneOption?: boolean;
hideButton?: boolean;
anchor?: RectCords;
};
export function PersonaPicker({
tab = PersonaPickerTab.Global,
function PersonaSelectMenuTabs({
tab,
setTab,
}: {
tab: PersonaPickerTab;
setTab: (tab: PersonaPickerTab) => void;
}) {
return (
<Box gap="100" style={{ marginBlock: '0.25rem' }}>
<Badge
style={pillStyles}
as="button"
variant="Secondary"
fill={tab == PersonaPickerTab.Global ? 'Solid' : 'None'}
size="500"
onClick={() => setTab(PersonaPickerTab.Global)}
>
<Text as="span" size="L400">
Global
</Text>
</Badge>
<Badge
style={pillStyles}
as="button"
variant="Secondary"
fill={tab == PersonaPickerTab.PerRoom ? 'Solid' : 'None'}
size="500"
onClick={() => setTab(PersonaPickerTab.PerRoom)}
>
<Text as="span" size="L400">
Per-room
</Text>
</Badge>
</Box>
);
}
export function TemporaryPersonaPicker(props: PersonaPickerProps) {
return (
<PersonaPicker {...props} presentation={PersonaPickerPresentation.TemporarySelectorMenu} />
);
}
export function PersistentPersonaPicker(props: PersonaPickerProps) {
return <PersonaPicker {...props} presentation={PersonaPickerPresentation.PersistentPicker} />;
}
function PersonaPicker({
tab: tabProp = PersonaPickerTab.Global,
mx,
roomId,
suppressEditorRefocus,
onTabChange,
latchedPersona,
}: PersonaPickerProps) {
onPersonaSelect,
anchor,
requestClose,
presentation,
onTabChange,
}: PersonaPickerProps & { presentation: PersonaPickerPresentation }) {
const useAuthentication = useMediaAuthentication();
const activeTheme = useActiveTheme();
const [AddPersonaMenuAnchor, setAddPersonaMenuAnchor] = useState<RectCords>();
const persistent = presentation === PersonaPickerPresentation.PersistentPicker;
const [tab, setTab] = useState(tabProp);
const [AddPersonaMenuAnchor, setAddPersonaMenuAnchor] = useState<RectCords | undefined>(anchor);
const [profiles, setProfiles] = useState<PerMessageProfile[] | undefined>(undefined);
const [selectedGlobalPersona, setSelectedGlobalPersona] = useState<PerMessageProfile | null>(
null
@@ -75,41 +138,20 @@ export function PersonaPicker({
const [selectedRoomPersona, setSelectedRoomPersona] = useState<PerMessageProfile | null>(
latchedPersona ?? null
);
const isPickerMenuItemSelected = (persona: PerMessageProfile) => {
const selectedPersona =
tab === PersonaPickerTab.Global ? selectedGlobalPersona : selectedRoomPersona;
return persona.id === selectedPersona?.id ? true : undefined;
};
const nameColor = useCallback(
(persona: PerMessageProfile) =>
activeTheme.kind === ThemeKind.Dark ? persona.colors?.on_dark : persona.colors?.on_light,
[activeTheme]
);
const defactoPersona = () => selectedRoomPersona ?? selectedGlobalPersona;
const searchInputRef = useRef<HTMLInputElement>(null);
const scrollRef = useRef<HTMLDivElement>(null);
const [filteredProfiles, setFilteredProfiles] = useState<PerMessageProfile[] | undefined>(
undefined
);
const clearFilterInput = () => {
if (searchInputRef.current) {
searchInputRef.current.value = '';
}
setFilteredProfiles(profiles);
};
const activeTheme = useActiveTheme();
useEffect(() => {
const syncProfile = async () => {
const syncedRoomProfile = await getCurrentlyUsedPerMessageProfileForRoom(mx, roomId);
if (!selectedRoomPersona) setSelectedRoomPersona(syncedRoomProfile ?? null);
if (roomId) {
const syncedRoomProfile = await getCurrentlyUsedPerMessageProfileForRoom(mx, roomId);
if (!selectedRoomPersona) setSelectedRoomPersona(syncedRoomProfile ?? null);
const syncedGlobalProfile = await getCurrentlyUsedPerMessageProfileForAccount(mx);
setSelectedGlobalPersona(syncedGlobalProfile ?? null);
const syncedGlobalProfile = await getCurrentlyUsedPerMessageProfileForAccount(mx);
setSelectedGlobalPersona(syncedGlobalProfile ?? null);
}
};
syncProfile();
}, [mx, roomId, profiles, latchedPersona, selectedRoomPersona]);
@@ -120,9 +162,8 @@ export function PersonaPicker({
setFilteredProfiles(fetchedProfiles);
};
useEffect(() => {
fetchProfiles(mx);
}, [mx]);
const scrollRef = useRef<HTMLDivElement>(null);
const searchInputRef = useRef<HTMLInputElement>(null);
const filter = useCallback(
(e: FormEvent) => {
@@ -141,6 +182,23 @@ export function PersonaPicker({
},
[profiles]
);
const nameColor = useCallback(
(persona: PerMessageProfile) =>
activeTheme.kind === ThemeKind.Dark ? persona.colors?.on_dark : persona.colors?.on_light,
[activeTheme]
);
const isSelected = (persona: PerMessageProfile | undefined) => {
if (!persona) return undefined;
const selected = tab === PersonaPickerTab.Global ? selectedGlobalPersona : selectedRoomPersona;
return persona.id === selected?.id ? true : undefined;
};
const [filteredProfiles, setFilteredProfiles] = useState(profiles);
useEffect(() => {
fetchProfiles(mx);
}, [mx]);
const avatarUrl = useCallback(
(profile: PerMessageProfile) => {
@@ -153,16 +211,58 @@ export function PersonaPicker({
[mx, useAuthentication]
);
const handleSelect = useCallback(
async (profile: PerMessageProfile | undefined) => {
if (onPersonaSelect) {
onPersonaSelect(profile);
return;
}
if (!roomId) return;
const isGlobal = tab === PersonaPickerTab.Global;
const selectedPersona = isGlobal ? selectedGlobalPersona : selectedRoomPersona;
const disabling = !profile || profile.id === selectedPersona?.id;
if (!disabling) {
if (isGlobal) {
setSelectedGlobalPersona(profile);
await setCurrentlyUsedPerMessageProfileIdForAccount(mx, profile.id);
} else {
setSelectedRoomPersona(profile);
await setCurrentlyUsedPerMessageProfileIdForRoom(mx, roomId, profile.id);
}
} else {
if (isGlobal) {
setSelectedGlobalPersona(null);
await setCurrentlyUsedPerMessageProfileIdForAccount(mx, undefined, undefined, true);
} else {
setSelectedRoomPersona(null);
await setCurrentlyUsedPerMessageProfileIdForRoom(mx, roomId, undefined, undefined, true);
}
}
},
[
mx,
roomId,
tab,
selectedRoomPersona,
selectedGlobalPersona,
setSelectedGlobalPersona,
setSelectedRoomPersona,
onPersonaSelect,
]
);
return (
<ResponsiveMenu
anchor={AddPersonaMenuAnchor}
position="Top"
position={!persistent ? 'Left' : 'Top'}
align="Start"
offset={16}
alignOffset={-44}
offset={!persistent ? 10 : 16}
alignOffset={!persistent ? 0 : -44}
requestClose={() => {
setAddPersonaMenuAnchor(undefined);
clearFilterInput();
requestClose?.();
}}
menu={
<Menu>
@@ -171,33 +271,15 @@ export function PersonaPicker({
gap="100"
style={{ padding: config.space.S200, minWidth: '18rem' }}
>
<Box gap="100">
<Badge
style={pillStyles}
as="button"
variant="Secondary"
fill={tab == PersonaPickerTab.Global ? 'Solid' : 'None'}
size="500"
onClick={() => onTabChange(PersonaPickerTab.Global)}
>
<Text as="span" size="L400">
Global
</Text>
</Badge>
<Badge
style={pillStyles}
as="button"
variant="Secondary"
fill={tab == PersonaPickerTab.PerRoom ? 'Solid' : 'None'}
size="500"
onClick={() => onTabChange(PersonaPickerTab.PerRoom)}
>
<Text as="span" size="L400">
Per-room
</Text>
</Badge>
</Box>
{persistent && (
<PersonaSelectMenuTabs
tab={tab}
setTab={(newTab) => {
onTabChange?.(newTab);
setTab(newTab);
}}
/>
)}
<>
<Input
ref={searchInputRef}
@@ -210,50 +292,20 @@ export function PersonaPicker({
before={menuIcon(MagnifyingGlass)}
/>
<Scroll hideTrack ref={scrollRef} size="400" style={{ maxHeight: '10rem' }}>
<Scroll
hideTrack
ref={scrollRef}
size="400"
style={{ maxHeight: isMobileOrTablet() ? '55dvh' : '10rem' }}
>
{filteredProfiles?.map((profile) => (
<MenuItem
key={profile.id}
size="400"
radii="300"
className={css.PersonaPickerMenuItem}
aria-selected={isPickerMenuItemSelected(profile)}
onClick={async () => {
const isGlobal = tab === PersonaPickerTab.Global;
const selectedPersona = isGlobal
? selectedGlobalPersona
: selectedRoomPersona;
const disabling = profile.id === selectedPersona?.id;
if (!disabling) {
if (isGlobal) {
setSelectedGlobalPersona(profile);
await setCurrentlyUsedPerMessageProfileIdForAccount(mx, profile.id);
} else {
setSelectedRoomPersona(profile);
await setCurrentlyUsedPerMessageProfileIdForRoom(mx, roomId, profile.id);
}
} else {
if (isGlobal) {
setSelectedGlobalPersona(null);
await setCurrentlyUsedPerMessageProfileIdForAccount(
mx,
undefined,
undefined,
true
);
} else {
setSelectedRoomPersona(null);
await setCurrentlyUsedPerMessageProfileIdForRoom(
mx,
roomId,
undefined,
undefined,
true
);
}
}
}}
aria-selected={isSelected(profile)}
onClick={() => handleSelect(profile)}
before={
<Avatar
size="300"
@@ -287,72 +339,100 @@ export function PersonaPicker({
</Text>
</MenuItem>
))}
{presentation !== PersonaPickerPresentation.PersistentPicker && (
<MenuItem
key={'none'}
size="400"
radii="300"
className={css.PersonaPickerMenuItem}
onClick={() => handleSelect(undefined)}
before={
<div
style={{
width: 28,
height: 28,
marginLeft: -6,
}}
>
{menuIcon(XIcon, { weight: 'regular', size: 28 })}{' '}
</div>
}
>
<Text truncate style={{ maxWidth: toRem(150) }}>
No persona
</Text>
</MenuItem>
)}
</Scroll>
<InfoCard
before={menuIcon(InfoIcon, { weight: 'fill' })}
variant="Primary"
description={
selectedRoomPersona ? (
<>
Message will use your <em>per-room</em> persona.
</>
) : selectedGlobalPersona ? (
<>
Message will use your <em>global</em> persona.
</>
) : (
<>No persona chosen.</>
)
}
/>
{presentation === PersonaPickerPresentation.PersistentPicker && (
<InfoCard
before={menuIcon(InfoIcon, { weight: 'fill' })}
variant="Primary"
description={
selectedRoomPersona ? (
<>
Message will use your <em>per-room</em> persona.
</>
) : selectedGlobalPersona ? (
<>
Message will use your <em>global</em> persona.
</>
) : (
<>No persona chosen.</>
)
}
/>
)}
</>
</Box>
</Menu>
}
>
<IconButton
aria-pressed={!!AddPersonaMenuAnchor}
onClick={(evt) => {
// getAllPerMessageProfiles can return an empty list during initial startup.
if (profiles?.length === 0) {
fetchProfiles(mx);
}
setAddPersonaMenuAnchor(evt.currentTarget.getBoundingClientRect());
}}
onPointerDown={suppressEditorRefocus}
variant="SurfaceVariant"
size="300"
style={{ backgroundColor: 'transparent' }}
title="Switch persona"
aria-label="Switch persona"
>
{(selectedRoomPersona ?? selectedGlobalPersona) ? (
<Avatar
size="200"
radii="300"
className={
AddPersonaMenuAnchor
? css.SelectedPersonaPickerButtonAvatar
: css.PersonaPickerButtonAvatar
{persistent && (
<IconButton
aria-pressed={!!AddPersonaMenuAnchor}
onClick={(evt) => {
// getAllPerMessageProfiles can return an empty list during initial startup.
if (profiles?.length === 0) {
fetchProfiles(mx);
}
aria-label="Profile avatar"
>
<UserAvatar
className={css.PersonaPickerButtonAvatarImage}
userId={defactoPersona()!.id}
src={avatarUrl(defactoPersona()!)}
renderFallback={() => (
<Text as="span" size="H6" aria-label="Avatar fallback">
{nameInitials(defactoPersona()!.name)}
</Text>
)}
alt={`Avatar for profile ${defactoPersona()!.id}`}
/>
</Avatar>
) : (
composerIcon(UserIcon, { weight: AddPersonaMenuAnchor ? 'fill' : 'regular' })
)}
</IconButton>
setAddPersonaMenuAnchor(evt.currentTarget.getBoundingClientRect());
}}
onPointerDown={suppressEditorRefocus}
variant="SurfaceVariant"
size="300"
style={{ backgroundColor: 'transparent' }}
title="Switch persona"
aria-label="Switch persona"
>
{(selectedRoomPersona ?? selectedGlobalPersona) ? (
<Avatar
size="200"
radii="300"
className={
AddPersonaMenuAnchor
? css.SelectedPersonaPickerButtonAvatar
: css.PersonaPickerButtonAvatar
}
aria-label="Profile avatar"
>
<UserAvatar
className={css.PersonaPickerButtonAvatarImage}
userId={defactoPersona()!.id}
src={avatarUrl(defactoPersona()!)}
renderFallback={() => (
<Text as="span" size="H6" aria-label="Avatar fallback">
{nameInitials(defactoPersona()!.name)}
</Text>
)}
alt={`Avatar for profile ${defactoPersona()!.id}`}
/>
</Avatar>
) : (
composerIcon(UserIcon, { weight: AddPersonaMenuAnchor ? 'fill' : 'regular' })
)}
</IconButton>
)}
</ResponsiveMenu>
);
}