diff options
Diffstat (limited to 'webapp/components/post_view/components/reaction_container.jsx')
-rw-r--r-- | webapp/components/post_view/components/reaction_container.jsx | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/webapp/components/post_view/components/reaction_container.jsx b/webapp/components/post_view/components/reaction_container.jsx deleted file mode 100644 index 29936c60a..000000000 --- a/webapp/components/post_view/components/reaction_container.jsx +++ /dev/null @@ -1,90 +0,0 @@ -import PropTypes from 'prop-types'; - -// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. -// See License.txt for license information. - -import React from 'react'; - -import {addReaction, removeReaction} from 'actions/post_actions.jsx'; -import * as UserActions from 'actions/user_actions.jsx'; - -import UserStore from 'stores/user_store.jsx'; - -import Reaction from './reaction.jsx'; - -export default class ReactionContainer extends React.Component { - static propTypes = { - post: PropTypes.object.isRequired, - emojiName: PropTypes.string.isRequired, - reactions: PropTypes.arrayOf(PropTypes.object), - emojis: PropTypes.object.isRequired - } - - constructor(props) { - super(props); - - this.handleUsersChanged = this.handleUsersChanged.bind(this); - - this.getStateFromStore = this.getStateFromStore.bind(this); - - this.getProfilesForReactions = this.getProfilesForReactions.bind(this); - this.getMissingProfiles = this.getMissingProfiles.bind(this); - - this.state = this.getStateFromStore(props); - } - - componentDidMount() { - UserStore.addChangeListener(this.handleUsersChanged); - } - - componentWillReceiveProps(nextProps) { - if (nextProps.reactions !== this.props.reactions) { - this.setState(this.getStateFromStore(nextProps)); - } - } - - componentWillUnmount() { - UserStore.removeChangeListener(this.handleUsersChanged); - } - - handleUsersChanged() { - this.setState(this.getStateFromStore()); - } - - getStateFromStore(props = this.props) { - const profiles = this.getProfilesForReactions(props.reactions); - const otherUsers = props.reactions.length - profiles.length; - - return { - profiles, - otherUsers, - currentUserId: UserStore.getCurrentId() - }; - } - - getProfilesForReactions(reactions) { - return reactions.map((reaction) => { - return UserStore.getProfile(reaction.user_id); - }).filter((profile) => Boolean(profile)); - } - - getMissingProfiles() { - const ids = this.props.reactions.map((reaction) => reaction.user_id); - - UserActions.getMissingProfiles(ids); - } - - render() { - return ( - <Reaction - {...this.props} - {...this.state} - actions={{ - addReaction, - getMissingProfiles: this.getMissingProfiles, - removeReaction - }} - /> - ); - } -} |