@@ -2,11 +2,12 @@ import * as Sentry from '@sentry/react';
2
2
3
3
import TeamAvatar from 'sentry/components/avatar/teamAvatar' ;
4
4
import UserAvatar from 'sentry/components/avatar/userAvatar' ;
5
- import LoadingIndicator from 'sentry/components/loadingIndicator' ;
6
- import MemberListStore from 'sentry/stores/memberListStore' ;
7
5
import type { Actor } from 'sentry/types' ;
6
+ import { useMembers } from 'sentry/utils/useMembers' ;
8
7
import { useTeamsById } from 'sentry/utils/useTeamsById' ;
9
8
9
+ import Placeholder from '../placeholder' ;
10
+
10
11
import type { BaseAvatarProps } from './baseAvatar' ;
11
12
12
13
interface Props extends BaseAvatarProps {
@@ -24,12 +25,33 @@ function LoadTeamAvatar({
24
25
const team = teams . find ( t => t . id === teamId ) ;
25
26
26
27
if ( isLoading ) {
27
- return < LoadingIndicator mini /> ;
28
+ const size = `${ props . size } px` ;
29
+ return < Placeholder width = { size } height = { size } /> ;
28
30
}
29
31
30
32
return < TeamAvatar team = { team } { ...props } /> ;
31
33
}
32
34
35
+ /**
36
+ * Wrapper to assist loading the user from api or store
37
+ */
38
+ function LoadMemberAvatar ( {
39
+ userId,
40
+ ...props
41
+ } : { userId : string } & Omit < React . ComponentProps < typeof UserAvatar > , 'team' > ) {
42
+ debugger ;
43
+
44
+ const { members, fetching} = useMembers ( { ids : [ userId ] } ) ;
45
+ const user = members . find ( u => u . id === userId ) ;
46
+
47
+ if ( fetching ) {
48
+ const size = `${ props . size } px` ;
49
+ return < Placeholder shape = "circle" width = { size } height = { size } /> ;
50
+ }
51
+
52
+ return < UserAvatar user = { user } { ...props } /> ;
53
+ }
54
+
33
55
function ActorAvatar ( { size = 24 , hasTooltip = true , actor, ...props } : Props ) {
34
56
const otherProps = {
35
57
size,
@@ -38,8 +60,7 @@ function ActorAvatar({size = 24, hasTooltip = true, actor, ...props}: Props) {
38
60
} ;
39
61
40
62
if ( actor . type === 'user' ) {
41
- const user = actor . id ? MemberListStore . getById ( actor . id ) ?? actor : actor ;
42
- return < UserAvatar user = { user } { ...otherProps } /> ;
63
+ return < LoadMemberAvatar userId = { actor . id } { ...otherProps } /> ;
43
64
}
44
65
45
66
if ( actor . type === 'team' ) {
0 commit comments