Filter emojis that don't render in Chrome on Desktop

pull/180/head
Philipp Heckel 2022-04-04 20:44:40 -04:00
parent 4eba641ec3
commit 328aca48ab
3 changed files with 14 additions and 3 deletions

View File

@ -19,7 +19,7 @@ if [[ "$1" == *.js ]]; then
echo -n "// This file is generated by scripts/emoji-convert.sh to reduce the size 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 // Original data source: https://github.com/github/gemoji/blob/master/db/emoji.json
export const rawEmojis = " > "$1" 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 elif [[ "$1" == *.md ]]; then
echo "# Emoji reference echo "# Emoji reference

File diff suppressed because one or more lines are too long

View File

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