forked from zulip/zulip-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReactionUserList.js
56 lines (50 loc) · 1.43 KB
/
ReactionUserList.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* @flow strict-local */
import React, { PureComponent } from 'react';
import { FlatList } from 'react-native';
import { connect } from '../react-redux';
import type { Dispatch, UserOrBot } from '../types';
import UserItem from '../users/UserItem';
import { navigateToAccountDetails } from '../actions';
type Props = $ReadOnly<{|
dispatch: Dispatch,
reactedUserIds: $ReadOnlyArray<number>,
allUsersById: Map<number, UserOrBot>,
|}>;
/**
* Component showing who made a given reaction on a given message.
*
* Used within `MessageReactionList`.
*/
class ReactionUserList extends PureComponent<Props> {
handlePress = (userId: number) => {
const { dispatch } = this.props;
dispatch(navigateToAccountDetails(userId));
};
render() {
const { reactedUserIds, allUsersById } = this.props;
return (
<FlatList
data={reactedUserIds}
keyExtractor={userId => `${userId}`}
renderItem={({ item }) => {
const user = allUsersById.get(item);
if (!user) {
return null;
}
return (
<UserItem
key={user.user_id}
fullName={user.full_name}
avatarUrl={user.avatar_url}
email={user.email}
onPress={() => {
this.handlePress(user.user_id);
}}
/>
);
}}
/>
);
}
}
export default connect<{||}, _, _>()(ReactionUserList);