0
0
Fork 0

Make auto-play GIFs preference affect custom emojis in web UI (#5254)

This commit is contained in:
Eugen Rochko 2017-10-07 02:38:52 +02:00 committed by GitHub
parent 4413d81d7f
commit 45682f876d
5 changed files with 17 additions and 7 deletions

View file

@ -5,6 +5,8 @@ const trie = new Trie(Object.keys(unicodeMapping));
const assetHost = process.env.CDN_HOST || '';
let allowAnimations = false;
const emojify = (str, customEmojis = {}) => {
let rtn = '';
for (;;) {
@ -25,7 +27,8 @@ const emojify = (str, customEmojis = {}) => {
// 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;
@ -48,12 +51,14 @@ const emojify = (str, customEmojis = {}) => {
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({