2019-01-13 19:34:38 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { PureComponent } from 'react';
|
|
|
|
|
|
|
|
import { getAvatarURLByParticipantId } from '../../base/participants';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The type of the React {@code Component} props of {@code AbstractChatMessage}.
|
|
|
|
*/
|
|
|
|
export type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The URL of the avatar of the participant.
|
|
|
|
*/
|
|
|
|
_avatarURL: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The representation of a chat message.
|
|
|
|
*/
|
|
|
|
message: Object,
|
|
|
|
|
2019-05-03 19:41:09 +00:00
|
|
|
/**
|
|
|
|
* Whether or not the name of the participant which sent the message should
|
|
|
|
* be displayed.
|
|
|
|
*/
|
|
|
|
showDisplayName: boolean,
|
|
|
|
|
2019-01-13 19:34:38 +00:00
|
|
|
/**
|
|
|
|
* Invoked to receive translated strings.
|
|
|
|
*/
|
|
|
|
t: Function
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Abstract component to display a chat message.
|
|
|
|
*/
|
2019-05-03 19:41:09 +00:00
|
|
|
export default class AbstractChatMessage<P: Props> extends PureComponent<P> {
|
|
|
|
static defaultProps = {
|
|
|
|
showDisplayName: true
|
|
|
|
};
|
|
|
|
}
|
2019-01-13 19:34:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Maps part of the Redux state to the props of this component.
|
|
|
|
*
|
|
|
|
* @param {Object} state - The Redux state.
|
|
|
|
* @param {Props} ownProps - The own props of the component.
|
|
|
|
* @returns {{
|
|
|
|
* _avatarURL: string
|
|
|
|
* }}
|
|
|
|
*/
|
|
|
|
export function _mapStateToProps(state: Object, ownProps: Props) {
|
|
|
|
const { message } = ownProps;
|
|
|
|
|
|
|
|
return {
|
2019-04-25 13:17:49 +00:00
|
|
|
_avatarURL: getAvatarURLByParticipantId(state, message.id)
|
2019-01-13 19:34:38 +00:00
|
|
|
};
|
|
|
|
}
|