From 8a39d160f6e0c0626181279163c95ac88f01e0c5 Mon Sep 17 00:00:00 2001 From: Florian Orben Date: Tue, 1 Dec 2015 22:40:24 +0100 Subject: switch to only use emoji one smileys; remove setting to switch --- web/react/components/post_body.jsx | 14 +--- web/react/components/rhs_root_post.jsx | 3 +- .../user_settings/user_settings_display.jsx | 85 +--------------------- web/react/stores/preference_store.jsx | 1 - web/react/utils/emoticons.jsx | 10 ++- web/react/utils/utils.jsx | 9 --- 6 files changed, 13 insertions(+), 109 deletions(-) (limited to 'web/react') diff --git a/web/react/components/post_body.jsx b/web/react/components/post_body.jsx index 75e4d735e..27f7ad2de 100644 --- a/web/react/components/post_body.jsx +++ b/web/react/components/post_body.jsx @@ -3,8 +3,8 @@ import FileAttachmentList from './file_attachment_list.jsx'; import UserStore from '../stores/user_store.jsx'; -import PreferenceStore from '../stores/preference_store.jsx'; import * as Utils from '../utils/utils.jsx'; +import * as Emoji from '../utils/emoticons.jsx'; import Constants from '../utils/constants.jsx'; import * as TextFormatting from '../utils/text_formatting.jsx'; import twemoji from 'twemoji'; @@ -20,7 +20,6 @@ export default class PostBody extends React.Component { this.isImgLoading = false; this.handleUserChange = this.handleUserChange.bind(this); - this.handlePreferenceChange = this.handlePreferenceChange.bind(this); this.parseEmojis = this.parseEmojis.bind(this); this.createEmbed = this.createEmbed.bind(this); this.createImageEmbed = this.createImageEmbed.bind(this); @@ -57,7 +56,7 @@ export default class PostBody extends React.Component { twemoji.parse(ReactDOM.findDOMNode(this), { className: 'emoji twemoji', base: '', - folder: Utils.getImagePathForEmoticon() + folder: Emoji.getImagePathForEmoticon() }); } @@ -71,7 +70,6 @@ export default class PostBody extends React.Component { this.parseEmojis(); UserStore.addChangeListener(this.handleUserChange); - PreferenceStore.addChangeListener(this.handlePreferenceChange); } componentDidUpdate() { @@ -80,7 +78,6 @@ export default class PostBody extends React.Component { componentWillUnmount() { UserStore.removeChangeListener(this.handleUserChange); - PreferenceStore.removeChangeListener(this.handlePreferenceChange); } handleUserChange() { @@ -91,13 +88,6 @@ export default class PostBody extends React.Component { } } - handlePreferenceChange() { - $('.twemoji').each((idx, elem) => { - elem.src = Utils.getImagePathForEmoticon(twemoji.convert.toCodePoint(elem.alt)); - }); - this.forceUpdate(); - } - componentWillReceiveProps(nextProps) { const linkData = Utils.extractLinks(nextProps.post.message); if (this.props.post.filenames.length === 0 && this.state.links && this.state.links.length > 0) { diff --git a/web/react/components/rhs_root_post.jsx b/web/react/components/rhs_root_post.jsx index 8a9ca2009..0dd969ad0 100644 --- a/web/react/components/rhs_root_post.jsx +++ b/web/react/components/rhs_root_post.jsx @@ -6,6 +6,7 @@ import UserProfile from './user_profile.jsx'; import UserStore from '../stores/user_store.jsx'; import * as TextFormatting from '../utils/text_formatting.jsx'; import * as utils from '../utils/utils.jsx'; +import * as Emoji from '../utils/emoticons.jsx'; import FileAttachmentList from './file_attachment_list.jsx'; import twemoji from 'twemoji'; import PostBodyAdditionalContent from './post_body_additional_content.jsx'; @@ -23,7 +24,7 @@ export default class RhsRootPost extends React.Component { twemoji.parse(ReactDOM.findDOMNode(this), { className: 'emoji twemoji', base: '', - folder: utils.getImagePathForEmoticon() + folder: Emoji.getImagePathForEmoticon() }); } componentDidMount() { diff --git a/web/react/components/user_settings/user_settings_display.jsx b/web/react/components/user_settings/user_settings_display.jsx index c83b74e62..43c8d33d1 100644 --- a/web/react/components/user_settings/user_settings_display.jsx +++ b/web/react/components/user_settings/user_settings_display.jsx @@ -6,17 +6,14 @@ import SettingItemMin from '../setting_item_min.jsx'; import SettingItemMax from '../setting_item_max.jsx'; import Constants from '../../utils/constants.jsx'; import PreferenceStore from '../../stores/preference_store.jsx'; -import * as Utils from '../../utils/utils.jsx'; function getDisplayStateFromStores() { const militaryTime = PreferenceStore.getPreference(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'use_military_time', {value: 'false'}); const nameFormat = PreferenceStore.getPreference(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'name_format', {value: 'username'}); - const emojiStyle = PreferenceStore.getPreference(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'emoji_style', {value: 'default'}); return { militaryTime: militaryTime.value, - nameFormat: nameFormat.value, - emojiStyle: emojiStyle.value + nameFormat: nameFormat.value }; } @@ -34,9 +31,8 @@ export default class UserSettingsDisplay extends React.Component { handleSubmit() { const timePreference = PreferenceStore.setPreference(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'use_military_time', this.state.militaryTime); const namePreference = PreferenceStore.setPreference(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'name_format', this.state.nameFormat); - const emojiStyle = PreferenceStore.setPreference(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'emoji_style', this.state.emojiStyle); - savePreferences([timePreference, namePreference, emojiStyle], + savePreferences([timePreference, namePreference], () => { PreferenceStore.emitChange(); this.updateSection(''); @@ -52,9 +48,6 @@ export default class UserSettingsDisplay extends React.Component { handleNameRadio(nameFormat) { this.setState({nameFormat}); } - handleEmojiRadio(emojiStyle) { - this.setState({emojiStyle}); - } updateSection(section) { this.setState(getDisplayStateFromStores()); this.props.updateSection(section); @@ -63,7 +56,6 @@ export default class UserSettingsDisplay extends React.Component { const serverError = this.state.serverError || null; let clockSection; let nameFormatSection; - let emojiSection; if (this.props.activeSection === 'clock') { const clockFormat = [false, false]; if (this.state.militaryTime === 'true') { @@ -217,77 +209,6 @@ export default class UserSettingsDisplay extends React.Component { ); } - if (this.props.activeSection === 'emoji') { - const inputs = [ -
-
- -
-
-
- -
-
-

{'Select how you prefer time displayed.'}
-
- ]; - - emojiSection = ( - { - this.updateSection(''); - e.preventDefault(); - }} - /> - ); - } else { - const describe = this.state.emojiStyle === 'default' ? 'Default Style' : 'Emoji One Style'; - emojiSection = ( - { - this.props.updateSection('emoji'); - }} - /> - ); - } - return (
@@ -318,8 +239,6 @@ export default class UserSettingsDisplay extends React.Component {
{nameFormatSection}
- {emojiSection} -
); diff --git a/web/react/stores/preference_store.jsx b/web/react/stores/preference_store.jsx index 69a4c166b..068bc29c2 100644 --- a/web/react/stores/preference_store.jsx +++ b/web/react/stores/preference_store.jsx @@ -122,6 +122,5 @@ class PreferenceStoreClass extends EventEmitter { } const PreferenceStore = new PreferenceStoreClass(); -PreferenceStore.setMaxListeners(0); export default PreferenceStore; window.PreferenceStore = PreferenceStore; diff --git a/web/react/utils/emoticons.jsx b/web/react/utils/emoticons.jsx index 6a8ba6984..8943e9544 100644 --- a/web/react/utils/emoticons.jsx +++ b/web/react/utils/emoticons.jsx @@ -1,8 +1,6 @@ // Copyright (c) 2015 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import * as Utils from './utils.jsx'; - const emoticonPatterns = { smile: /(^|\s)(:-?\))(?=$|\s)/g, // :) wink: /(^|\s)(;-?\))(?=$|\s)/g, // ;) @@ -135,7 +133,7 @@ export function handleEmoticons(text, tokens) { const alias = `MM_EMOTICON${index}`; tokens.set(alias, { - value: `${matchText}`, + value: `${matchText}`, originalText: fullMatch }); @@ -156,3 +154,9 @@ export function handleEmoticons(text, tokens) { return output; } +export function getImagePathForEmoticon(name) { + if (name) { + return `/static/images/emoji/${name}.png`; + } + return `/static/images/emoji`; +} \ No newline at end of file diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx index df323eb0f..f38d3e051 100644 --- a/web/react/utils/utils.jsx +++ b/web/react/utils/utils.jsx @@ -1226,13 +1226,4 @@ export function getPostTerm(post) { export function isFeatureEnabled(feature) { return PreferenceStore.getPreference(Constants.Preferences.CATEGORY_ADVANCED_SETTINGS, Constants.FeatureTogglePrefix + feature.label, {value: 'false'}).value === 'true'; -} - -export function getImagePathForEmoticon(name, style) { - const emojiStyle = style || PreferenceStore.getPreference(Constants.Preferences.CATEGORY_DISPLAY_SETTINGS, 'emoji_style', {value: 'default'}).value; - - if (name) { - return `/static/images/emoji/${emojiStyle}/${name}.png`; - } - return `/static/images/emoji/${emojiStyle}`; } \ No newline at end of file -- cgit v1.2.3-1-g7c22