2019-05-20 20:43:50 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2019-09-03 19:27:57 +00:00
|
|
|
import { TouchableOpacity } from 'react-native';
|
2019-05-20 20:43:50 +00:00
|
|
|
|
|
|
|
import Avatar from '../Avatar';
|
|
|
|
import styles from './styles';
|
|
|
|
|
|
|
|
const MessageAvatar = React.memo(({
|
2019-09-03 19:27:57 +00:00
|
|
|
isHeader, avatar, author, baseUrl, user, small, navToRoomInfo
|
2019-05-20 20:43:50 +00:00
|
|
|
}) => {
|
|
|
|
if (isHeader) {
|
2019-09-03 19:27:57 +00:00
|
|
|
const navParam = {
|
|
|
|
t: 'd',
|
|
|
|
rid: author._id
|
|
|
|
};
|
2019-05-20 20:43:50 +00:00
|
|
|
return (
|
2019-09-03 19:27:57 +00:00
|
|
|
<TouchableOpacity
|
|
|
|
onPress={() => navToRoomInfo(navParam)}
|
|
|
|
disabled={author._id === user.id}
|
|
|
|
>
|
|
|
|
<Avatar
|
|
|
|
style={small ? styles.avatarSmall : styles.avatar}
|
|
|
|
text={avatar ? '' : author.username}
|
|
|
|
size={small ? 20 : 36}
|
|
|
|
borderRadius={small ? 2 : 4}
|
|
|
|
avatar={avatar}
|
|
|
|
baseUrl={baseUrl}
|
|
|
|
userId={user.id}
|
|
|
|
token={user.token}
|
|
|
|
/>
|
|
|
|
</TouchableOpacity>
|
2019-05-20 20:43:50 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
return null;
|
2019-10-07 20:56:30 +00:00
|
|
|
});
|
2019-05-20 20:43:50 +00:00
|
|
|
|
|
|
|
MessageAvatar.propTypes = {
|
|
|
|
isHeader: PropTypes.bool,
|
|
|
|
avatar: PropTypes.string,
|
|
|
|
author: PropTypes.obj,
|
|
|
|
baseUrl: PropTypes.string,
|
|
|
|
user: PropTypes.obj,
|
2019-09-03 19:27:57 +00:00
|
|
|
small: PropTypes.bool,
|
|
|
|
navToRoomInfo: PropTypes.func
|
2019-05-20 20:43:50 +00:00
|
|
|
};
|
|
|
|
MessageAvatar.displayName = 'MessageAvatar';
|
|
|
|
|
|
|
|
export default MessageAvatar;
|