static propTypes = {
custom_emojis: ImmutablePropTypes.list,
+ autoPlay: PropTypes.bool,
intl: PropTypes.object.isRequired,
onPickEmoji: PropTypes.func.isRequired,
};
}
onShowDropdown = () => {
+ const { autoPlay } = this.props;
+
this.setState({ active: true });
if (!EmojiPicker) {
EmojiPicker = EmojiMart.Picker;
Emoji = EmojiMart.Emoji;
// populate custom emoji in search
- EmojiMart.emojiIndex.search('', { custom: buildCustomEmojis(this.props.custom_emojis) });
+ EmojiMart.emojiIndex.search('', { custom: buildCustomEmojis(this.props.custom_emojis, autoPlay) });
this.setState({ loading: false });
}).catch(() => {
this.setState({ loading: false });
const mapStateToProps = state => ({
custom_emojis: state.get('custom_emojis'),
+ autoPlay: state.getIn(['meta', 'auto_play_gif']),
});
export default connect(mapStateToProps)(EmojiPickerDropdown);
const assetHost = process.env.CDN_HOST || '';
+let allowAnimations = false;
+
const emojify = (str, customEmojis = {}) => {
let rtn = '';
for (;;) {
// now got a replacee as ':shortname:'
// if you want additional emoji handler, add statements below which set replacement and return true.
if (shortname in customEmojis) {
- replacement = `<img draggable="false" class="emojione" alt="${shortname}" title="${shortname}" src="${customEmojis[shortname]}" />`;
+ const filename = allowAnimations ? customEmojis[shortname].url : customEmojis[shortname].static_url;
+ replacement = `<img draggable="false" class="emojione" alt="${shortname}" title="${shortname}" src="${filename}" />`;
return true;
}
return false;
export default emojify;
-export const buildCustomEmojis = customEmojis => {
+export const buildCustomEmojis = (customEmojis, overrideAllowAnimations = false) => {
const emojis = [];
+ allowAnimations = overrideAllowAnimations;
+
customEmojis.forEach(emoji => {
const shortcode = emoji.get('shortcode');
- const url = emoji.get('static_url');
+ const url = allowAnimations ? emoji.get('url') : emoji.get('static_url');
const name = shortcode.replace(':', '');
emojis.push({
export default function custom_emojis(state = initialState, action) {
switch(action.type) {
case STORE_HYDRATE:
- emojiSearch('', { custom: buildCustomEmojis(action.state.get('custom_emojis', [])) });
+ emojiSearch('', { custom: buildCustomEmojis(action.state.get('custom_emojis', []), action.state.getIn(['meta', 'auto_play_gif'], false)) });
return action.state.get('custom_emojis');
default:
return state;
normalStatus.reblog = status.reblog.id;
}
- const searchContent = [status.spoiler_text, status.content].join(' ').replace(/<br \/>/g, '\n').replace(/<\/p><p>/g, '\n\n');
+ const searchContent = [status.spoiler_text, status.content].join('\n\n').replace(/<br \/>/g, '\n').replace(/<\/p><p>/g, '\n\n');
+
const emojiMap = normalStatus.emojis.reduce((obj, emoji) => {
- obj[`:${emoji.shortcode}:`] = emoji.static_url;
+ obj[`:${emoji.shortcode}:`] = emoji;
return obj;
}, {});