@@ -6,7 +6,6 @@ import type { UserId } from '../types';
66import { createStyleSheet } from '../styles' ;
77import UserAvatar from './UserAvatar' ;
88import PresenceStatusIndicator from './PresenceStatusIndicator' ;
9- import { AvatarURL } from '../utils/avatar' ;
109import { tryGetUserForId } from '../users/userSelectors' ;
1110import { useSelector } from '../react-redux' ;
1211
@@ -19,57 +18,21 @@ const styles = createStyleSheet({
1918} ) ;
2019
2120type Props = $ReadOnly < { |
22- avatarUrl : AvatarURL ,
21+ userId : UserId ,
2322 size : number ,
2423 onPress ?: ( ) => void ,
25- email : string ,
2624 isMuted ? : boolean ,
2725| } > ;
2826
2927/**
3028 * A user avatar with a PresenceStatusIndicator in the corner.
3129 *
32- * Prefer `UserAvatarWithPresenceById` over this component: it does the same
33- * thing but avoids an email in the component's interface. Once all callers
34- * have migrated to that version, it'll replace this one.
35- *
36- * @prop [avatarUrl]
37- * @prop [email] - Sender's / user's email address, for the presence dot.
38- * @prop [size] - Sets width and height in logical pixels.
39- * @prop [onPress] - Event fired on pressing the component.
40- */
41- export default function UserAvatarWithPresence ( props : Props ) : Node {
42- const { avatarUrl, email, isMuted, size, onPress } = props ;
43-
44- return (
45- < UserAvatar avatarUrl = { avatarUrl } size = { size } isMuted = { isMuted } onPress = { onPress } >
46- < PresenceStatusIndicator
47- style = { styles . status }
48- email = { email }
49- hideIfOffline
50- useOpaqueBackground
51- />
52- </ UserAvatar >
53- ) ;
54- }
55-
56- /**
57- * A user avatar with a PresenceStatusIndicator in the corner.
58- *
59- * Use this in preference to the default export `UserAvatarWithPresence`.
60- * We're migrating from that one to this in order to avoid using emails.
61- *
6230 * @prop [userId]
6331 * @prop [size]
6432 * @prop [onPress]
6533 */
66- export function UserAvatarWithPresenceById (
67- props : $ReadOnly < { |
68- ...$Diff < Props , { | avatarUrl : mixed , email : mixed | } > ,
69- userId : UserId ,
70- | } > ,
71- ) : Node {
72- const { userId, ...restProps } = props ;
34+ export default function UserAvatarWithPresence ( props : Props ) : Node {
35+ const { userId, isMuted, size, onPress } = props ;
7336
7437 const user = useSelector ( state => tryGetUserForId ( state , userId ) ) ;
7538 if ( ! user ) {
@@ -79,5 +42,14 @@ export function UserAvatarWithPresenceById(
7942 return null ;
8043 }
8144
82- return < UserAvatarWithPresence { ...restProps } avatarUrl = { user . avatar_url } email = { user . email } /> ;
45+ return (
46+ < UserAvatar avatarUrl = { user . avatar_url } size = { size } isMuted = { isMuted } onPress = { onPress } >
47+ < PresenceStatusIndicator
48+ style = { styles . status }
49+ email = { user . email }
50+ hideIfOffline
51+ useOpaqueBackground
52+ />
53+ </ UserAvatar >
54+ ) ;
8355}
0 commit comments