about summary refs log tree commit diff
path: root/app/assets/javascripts/components
diff options
context:
space:
mode:
authorEugen <eugen@zeonfederated.com>2017-01-05 13:37:29 +0100
committerGitHub <noreply@github.com>2017-01-05 13:37:29 +0100
commitc3c9879b5e319a0192a172b34c7c2fd4f3d35da5 (patch)
treec405cc14ed2ec8339722ae7a4ed552871e713184 /app/assets/javascripts/components
parentdf89cb5488f4d54c71048c6ee6b2c608a0a8ab50 (diff)
parent53b765f4b150d7671d697eed7333c948622045cf (diff)
Merge pull request #404 from mistydemeo/emoji
Display native emoji on browsers which support it
Diffstat (limited to 'app/assets/javascripts/components')
-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..990aea5be 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 < 9.0) {
+    return emojione.toImage(text);
+  // Convert short codes into native emoji
+  } else {
+    return emojione.shortnameToUnicode(text);
+  }
 };