@@ -10,7 +10,7 @@ import { useMediaAuthentication } from '$hooks/useMediaAuthentication.ts';
1010import {
1111 getCurrentlyUsedPerMessageProfileForRoom ,
1212 getAllPerMessageProfiles ,
13- type PerMessageProfile ,
13+ type PerMessageProfileMsc4461 ,
1414 setCurrentlyUsedPerMessageProfileIdForRoom ,
1515 getCurrentlyUsedPerMessageProfileForAccount ,
1616 setCurrentlyUsedPerMessageProfileIdForAccount ,
@@ -58,9 +58,9 @@ type PersonaPickerProps = {
5858 roomId ?: string ;
5959 suppressEditorRefocus ?: ( ) => void ;
6060 onTabChange ?: ( tab : PersonaPickerTab ) => void ;
61- latchedPersona ?: PerMessageProfile ;
61+ latchedPersona ?: PerMessageProfileMsc4461 ;
6262 hideTabs ?: boolean ;
63- onPersonaSelect ?: ( persona : PerMessageProfile | undefined ) => void ;
63+ onPersonaSelect ?: ( persona : PerMessageProfileMsc4461 | undefined ) => void ;
6464 requestClose ?: ( ) => void ;
6565 showNoneOption ?: boolean ;
6666 hideButton ?: boolean ;
@@ -126,22 +126,26 @@ function PersonaPicker({
126126 onTabChange,
127127} : PersonaPickerProps & { presentation : PersonaPickerPresentation } ) {
128128 const useAuthentication = useMediaAuthentication ( ) ;
129-
130129 const persistent = presentation === PersonaPickerPresentation . PersistentPicker ;
131-
132130 const [ tab , setTab ] = useState ( tabProp ) ;
133131 const [ AddPersonaMenuAnchor , setAddPersonaMenuAnchor ] = useState < RectCords | undefined > ( anchor ) ;
134- const [ profiles , setProfiles ] = useState < PerMessageProfile [ ] | undefined > ( undefined ) ;
135- const [ selectedGlobalPersona , setSelectedGlobalPersona ] = useState < PerMessageProfile | null > (
136- null
137- ) ;
138- const [ selectedRoomPersona , setSelectedRoomPersona ] = useState < PerMessageProfile | null > (
132+ const activeTheme = useActiveTheme ( ) ;
133+ const [ profiles , setProfiles ] = useState < PerMessageProfileMsc4461 [ ] | undefined > ( undefined ) ;
134+ const [ selectedGlobalPersona , setSelectedGlobalPersona ] =
135+ useState < PerMessageProfileMsc4461 | null > ( null ) ;
136+ const [ selectedRoomPersona , setSelectedRoomPersona ] = useState < PerMessageProfileMsc4461 | null > (
139137 latchedPersona ?? null
140138 ) ;
141139
142- const defactoPersona = ( ) => selectedRoomPersona ?? selectedGlobalPersona ;
140+ const nameColor = useCallback (
141+ ( persona : PerMessageProfileMsc4461 ) =>
142+ activeTheme . kind === ThemeKind . Dark
143+ ? persona [ 'eu.she-a.color' ] ?. on_dark
144+ : persona [ 'eu.she-a.color' ] ?. on_light ,
145+ [ activeTheme ]
146+ ) ;
143147
144- const activeTheme = useActiveTheme ( ) ;
148+ const defactoPersona = ( ) => selectedRoomPersona ?? selectedGlobalPersona ;
145149
146150 useEffect ( ( ) => {
147151 const syncProfile = async ( ) => {
@@ -172,7 +176,7 @@ function PersonaPicker({
172176 const filtered = term
173177 ? profiles ?. filter ( ( profile ) =>
174178 searchInputRef . current
175- ? profile . name . toLocaleLowerCase ( ) . includes ( searchInputRef . current ?. value ) ||
179+ ? profile . displayname . toLocaleLowerCase ( ) . includes ( searchInputRef . current ?. value ) ||
176180 profile . id . toLocaleLowerCase ( ) . includes ( searchInputRef . current ?. value )
177181 : true
178182 )
@@ -182,13 +186,8 @@ function PersonaPicker({
182186 } ,
183187 [ profiles ]
184188 ) ;
185- const nameColor = useCallback (
186- ( persona : PerMessageProfile ) =>
187- activeTheme . kind === ThemeKind . Dark ? persona . colors ?. on_dark : persona . colors ?. on_light ,
188- [ activeTheme ]
189- ) ;
190189
191- const isSelected = ( persona : PerMessageProfile | undefined ) => {
190+ const isSelected = ( persona : PerMessageProfileMsc4461 | undefined ) => {
192191 if ( ! persona ) return undefined ;
193192 const selected = tab === PersonaPickerTab . Global ? selectedGlobalPersona : selectedRoomPersona ;
194193 return persona . id === selected ?. id ? true : undefined ;
@@ -201,9 +200,9 @@ function PersonaPicker({
201200 } , [ mx ] ) ;
202201
203202 const avatarUrl = useCallback (
204- ( profile : PerMessageProfile ) => {
205- if ( profile . avatarUrl !== undefined ) {
206- return mxcUrlToHttp ( mx , profile . avatarUrl , useAuthentication , 96 , 96 , 'crop' ) ?? undefined ;
203+ ( profile : PerMessageProfileMsc4461 ) => {
204+ if ( profile . avatar_url !== undefined ) {
205+ return mxcUrlToHttp ( mx , profile . avatar_url , useAuthentication , 96 , 96 , 'crop' ) ?? undefined ;
207206 } else {
208207 return undefined ;
209208 }
@@ -212,7 +211,7 @@ function PersonaPicker({
212211 ) ;
213212
214213 const handleSelect = useCallback (
215- async ( profile : PerMessageProfile | undefined ) => {
214+ async ( profile : PerMessageProfileMsc4461 | undefined ) => {
216215 if ( onPersonaSelect ) {
217216 onPersonaSelect ( profile ) ;
218217 return ;
@@ -320,10 +319,10 @@ function PersonaPicker({
320319 < UserAvatar
321320 userId = { profile . id }
322321 src = { avatarUrl ( profile ) }
323- fallbackColor = { profile . colors ?. on_light ?? undefined }
322+ fallbackColor = { profile [ 'eu.she-a.color' ] ?. on_light ?? undefined }
324323 renderFallback = { ( ) => (
325324 < Text as = "span" size = "H4" aria-label = "Avatar fallback" >
326- { nameInitials ( profile . name ) }
325+ { nameInitials ( profile . displayname ) }
327326 </ Text >
328327 ) }
329328 alt = { `Avatar for profile ${ profile . id } ` }
@@ -335,7 +334,7 @@ function PersonaPicker({
335334 truncate
336335 style = { { color : nameColor ( profile ) ?? undefined , maxWidth : toRem ( 150 ) } }
337336 >
338- { profile . name }
337+ { profile . displayname }
339338 </ Text >
340339 </ MenuItem >
341340 ) ) }
@@ -422,7 +421,7 @@ function PersonaPicker({
422421 src = { avatarUrl ( defactoPersona ( ) ! ) }
423422 renderFallback = { ( ) => (
424423 < Text as = "span" size = "H6" aria-label = "Avatar fallback" >
425- { nameInitials ( defactoPersona ( ) ! . name ) }
424+ { nameInitials ( defactoPersona ( ) ! . displayname ) }
426425 </ Text >
427426 ) }
428427 alt = { `Avatar for profile ${ defactoPersona ( ) ! . id } ` }
0 commit comments