// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import EmojiListItem from './emoji_list_item.jsx'; import LoadingScreen from 'components/loading_screen.jsx'; import EmojiStore from 'stores/emoji_store.jsx'; import UserStore from 'stores/user_store.jsx'; import {loadEmoji} from 'actions/emoji_actions.jsx'; import * as AsyncClient from 'utils/async_client.jsx'; import * as Utils from 'utils/utils.jsx'; import React from 'react'; import {Link} from 'react-router'; import {FormattedMessage} from 'react-intl'; export default class EmojiList extends React.Component { static get propTypes() { return { team: React.PropTypes.object, user: React.PropTypes.object }; } constructor(props) { super(props); this.updateTitle = this.updateTitle.bind(this); this.handleEmojiChange = this.handleEmojiChange.bind(this); this.handleUserChange = this.handleUserChange.bind(this); this.deleteEmoji = this.deleteEmoji.bind(this); this.updateFilter = this.updateFilter.bind(this); this.state = { emojis: EmojiStore.getCustomEmojiMap(), loading: !EmojiStore.hasReceivedCustomEmojis(), filter: '', users: UserStore.getProfiles() }; } componentDidMount() { EmojiStore.addChangeListener(this.handleEmojiChange); UserStore.addChangeListener(this.handleUserChange); if (window.mm_config.EnableCustomEmoji === 'true') { loadEmoji(); } this.updateTitle(); } updateTitle() { let currentSiteName = ''; if (global.window.mm_config.SiteName != null) { currentSiteName = global.window.mm_config.SiteName; } document.title = Utils.localizeMessage('custom_emoji.header', 'Custom Emoji') + ' - ' + this.props.team.display_name + ' ' + currentSiteName; } componentWillUnmount() { EmojiStore.removeChangeListener(this.handleEmojiChange); UserStore.removeChangeListener(this.handleUserChange); } handleEmojiChange() { this.setState({ emojis: EmojiStore.getCustomEmojiMap(), loading: !EmojiStore.hasReceivedCustomEmojis() }); } handleUserChange() { this.setState({users: UserStore.getProfiles()}); } updateFilter(e) { this.setState({ filter: e.target.value }); } deleteEmoji(emoji) { AsyncClient.deleteEmoji(emoji.id); } render() { const filter = this.state.filter.toLowerCase(); const isSystemAdmin = Utils.isSystemAdmin(this.props.user.roles); const emojis = []; if (this.state.loading) { emojis.push(
|
|
|
|
---|