Merge branch 'emoji-pool-fix' into 'develop'

Populate emojis in autosuggest again

See merge request soapbox-pub/soapbox-fe!535
This commit is contained in:
Alex Gleason 2021-06-16 22:41:17 +00:00
commit ceee6ad755
2 changed files with 14 additions and 6 deletions

View file

@ -38,7 +38,7 @@ function clearCustomEmojis(pool) {
});
}
function addCustomToPool(custom, pool) {
export function addCustomToPool(custom, pool = originalPool) {
if (customEmojisList.length) clearCustomEmojis(pool);
custom.forEach((emoji) => {
@ -54,7 +54,7 @@ function addCustomToPool(custom, pool) {
index = {};
}
function search(value, { emojisToShowFilter, maxResults, include, exclude, custom } = {}) {
export function search(value, { emojisToShowFilter, maxResults, include, exclude, custom } = {}) {
if (custom !== undefined) {
if (customEmojisList !== custom)
addCustomToPool(custom, originalPool);
@ -181,5 +181,3 @@ function search(value, { emojisToShowFilter, maxResults, include, exclude, custo
return results;
}
export { search };

View file

@ -1,17 +1,27 @@
import { List as ImmutableList, fromJS } from 'immutable';
import { CUSTOM_EMOJIS_FETCH_SUCCESS } from '../actions/custom_emojis';
import { addCustomToPool } from 'soapbox/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 importEmojis = (state, emojis) => {
return fromJS(emojis).filter(emoji => {
// Populate custom emojis for composer autosuggest
const autosuggestPopulate = emojis => {
addCustomToPool(buildCustomEmojis(emojis));
};
const importEmojis = (state, customEmojis) => {
const emojis = fromJS(customEmojis).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];
});
autosuggestPopulate(emojis);
return emojis;
};
export default function custom_emojis(state = initialState, action) {