about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorMisty De Meo <mistydemeo@gmail.com>2017-01-04 22:23:02 -0800
committerMisty De Meo <mistydemeo@gmail.com>2017-01-04 22:23:02 -0800
commitc318e6e42e2903af90be205760a5a2ba00e378b8 (patch)
tree8da31c465ae1837445f8775e23839f6b781981fd /app
parent9bb1b97d2a31477ce3da83fb204dd5702323c1bb (diff)
Display native emoji on browsers which support it
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/components/emoji.jsx11
1 files changed, 10 insertions, 1 deletions
diff --git a/app/assets/javascripts/components/emoji.jsx b/app/assets/javascripts/components/emoji.jsx
index c93c07c74..82b82b719 100644
--- a/app/assets/javascripts/components/emoji.jsx
+++ b/app/assets/javascripts/components/emoji.jsx
@@ -1,9 +1,18 @@
 import emojione from 'emojione';
+import detectVersion from 'mojibaka';
 
 emojione.imageType    = 'png';
 emojione.sprites      = false;
 emojione.imagePathPNG = '/emoji/';
 
+let emoji_version = detectVersion();
+
 export default function emojify(text) {
-  return emojione.toImage(text);
+  // Browser too old to support native emoji
+  if (emoji_version < 6.1) {
+    return emojione.toImage(text);
+  // Convert short codes into native emoji
+  } else {
+    return emojione.shortnameToUnicode(text);
+  }
 };