Browse Source

Filter emojis that don't render in Chrome on Desktop

Philipp Heckel 2 years ago
parent
commit
328aca48ab
3 changed files with 13 additions and 2 deletions
  1. 1 1
      scripts/emoji-convert.sh
  2. 0 0
      web/src/app/emojis.js
  3. 12 1
      web/src/components/EmojiPicker.js

+ 1 - 1
scripts/emoji-convert.sh

@@ -19,7 +19,7 @@ if [[ "$1" == *.js ]]; then
   echo -n "// This file is generated by scripts/emoji-convert.sh to reduce the size
 // Original data source: https://github.com/github/gemoji/blob/master/db/emoji.json
 export const rawEmojis = " > "$1"
-    cat "$SCRIPTDIR/emoji.json" | jq -rc 'map({emoji: .emoji,aliases: .aliases, tags: .tags, category: .category, description: .description})' >> "$1"
+    cat "$SCRIPTDIR/emoji.json" | jq -rc 'map({emoji: .emoji, aliases: .aliases, tags: .tags, category: .category, description: .description, unicode_version: .unicode_version})' >> "$1"
 elif [[ "$1" == *.md ]]; then
   echo "# Emoji reference
 

File diff suppressed because it is too large
+ 0 - 0
web/src/app/emojis.js


+ 12 - 1
web/src/components/EmojiPicker.js

@@ -9,12 +9,23 @@ import {InputAdornment} from "@mui/material";
 import IconButton from "@mui/material/IconButton";
 import {Close} from "@mui/icons-material";
 
+// Create emoji list by category; filter emojis that are not supported by Desktop Chrome
 const emojisByCategory = {};
+const isDesktopChrome = /Chrome/.test(navigator.userAgent) && !/Mobile/.test(navigator.userAgent);
+const maxSupportedVersionForDesktopChrome = 11;
 rawEmojis.forEach(emoji => {
     if (!emojisByCategory[emoji.category]) {
         emojisByCategory[emoji.category] = [];
     }
-    emojisByCategory[emoji.category].push(emoji);
+    try {
+        const unicodeVersion = parseFloat(emoji.unicode_version);
+        const supportedEmoji = unicodeVersion <= maxSupportedVersionForDesktopChrome || !isDesktopChrome;
+        if (supportedEmoji) {
+            emojisByCategory[emoji.category].push(emoji);
+        }
+    } catch (e) {
+        // Nothing. Ignore.
+    }
 });
 
 const EmojiPicker = (props) => {

Some files were not shown because too many files changed in this diff