From c318e6e42e2903af90be205760a5a2ba00e378b8 Mon Sep 17 00:00:00 2001
From: Misty De Meo <mistydemeo@gmail.com>
Date: Wed, 4 Jan 2017 22:23:02 -0800
Subject: Display native emoji on browsers which support it

---
 app/assets/javascripts/components/emoji.jsx | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

(limited to 'app/assets/javascripts/components/emoji.jsx')

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);
+  }
 };
-- 
cgit 

