Skip custom emojis when they match a Unicode emoji's shortcode

datepicker-css
Alex Gleason 2021-06-16 16:48:23 -05:00
rodzic c0c6c52621
commit 2ef977a204
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 15 dodań i 7 usunięć

Wyświetl plik

@ -1,14 +1,22 @@
import { List as ImmutableList, fromJS as ConvertToImmutable } from 'immutable';
import { List as ImmutableList, fromJS } from 'immutable';
import { CUSTOM_EMOJIS_FETCH_SUCCESS } from '../actions/custom_emojis';
import { search as emojiSearch } from '../features/emoji/emoji_mart_search_light';
import { buildCustomEmojis } from '../features/emoji/emoji';
import { emojis as emojiData } from 'soapbox/features/emoji/emoji_mart_data_light';
const initialState = ImmutableList([]);
const initialState = ImmutableList();
const importEmojis = (state, emojis) => {
return fromJS(emojis).filter(emoji => {
// If a custom emoji has the shortcode of a Unicode emoji, skip it.
// Otherwise it breaks EmojiMart.
// https://gitlab.com/soapbox-pub/soapbox-fe/-/issues/610
const shortcode = emoji.get('shortcode', '').toLowerCase();
return !emojiData[shortcode];
});
};
export default function custom_emojis(state = initialState, action) {
if(action.type === CUSTOM_EMOJIS_FETCH_SUCCESS) {
state = ConvertToImmutable(action.custom_emojis);
emojiSearch('', { custom: buildCustomEmojis(state) });
if (action.type === CUSTOM_EMOJIS_FETCH_SUCCESS) {
return importEmojis(state, action.custom_emojis);
}
return state;