Exclude invalid recent emoji, simplify items redux structure
This commit is contained in:
parent
46b4cf56a3
commit
86a38d2f2b
4 changed files with 16 additions and 5 deletions
|
@ -87,7 +87,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function getItemsState() {
|
function getItemsState() {
|
||||||
return _.clone(items);
|
const data = _.clone(items);
|
||||||
|
const ids = Object.keys(data);
|
||||||
|
ids.forEach(id => {
|
||||||
|
data[id] = data[id].value;
|
||||||
|
});
|
||||||
|
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
|
|
|
@ -112,6 +112,10 @@ export const dataByCategory = mapValues(
|
||||||
arr => sortBy(arr, 'sort_order')
|
arr => sortBy(arr, 'sort_order')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export function isShortNameValid(shortName: string) {
|
||||||
|
return Boolean(dataByShortName[shortName]);
|
||||||
|
}
|
||||||
|
|
||||||
export function getSheetCoordinates(
|
export function getSheetCoordinates(
|
||||||
shortName: keyof typeof dataByShortName,
|
shortName: keyof typeof dataByShortName,
|
||||||
skinTone?: SkinToneKey | number
|
skinTone?: SkinToneKey | number
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { mapDispatchToProps } from '../actions';
|
||||||
import { EmojiButton, Props } from '../../components/emoji/EmojiButton';
|
import { EmojiButton, Props } from '../../components/emoji/EmojiButton';
|
||||||
import { StateType } from '../reducer';
|
import { StateType } from '../reducer';
|
||||||
|
|
||||||
|
import { isShortNameValid } from '../../components/emoji/lib';
|
||||||
import { getIntl } from '../selectors/user';
|
import { getIntl } from '../selectors/user';
|
||||||
|
|
||||||
const mapStateToProps = (state: StateType) => {
|
const mapStateToProps = (state: StateType) => {
|
||||||
|
@ -12,8 +13,8 @@ const mapStateToProps = (state: StateType) => {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
i18n: getIntl(state),
|
i18n: getIntl(state),
|
||||||
recentEmojis: recents,
|
recentEmojis: recents.filter(isShortNameValid),
|
||||||
skinTone: get(state, ['items', 'skinTone', 'value'], 0),
|
skinTone: get(state, ['items', 'skinTone'], 0),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -24,11 +24,11 @@ const mapStateToProps = (state: StateType) => {
|
||||||
const installedPack = getRecentlyInstalledStickerPack(state);
|
const installedPack = getRecentlyInstalledStickerPack(state);
|
||||||
const showIntroduction = get(
|
const showIntroduction = get(
|
||||||
state.items,
|
state.items,
|
||||||
['showStickersIntroduction', 'value'],
|
['showStickersIntroduction'],
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
const showPickerHint =
|
const showPickerHint =
|
||||||
get(state.items, ['showStickerPickerHint', 'value'], false) &&
|
get(state.items, ['showStickerPickerHint'], false) &&
|
||||||
receivedPacks.length > 0;
|
receivedPacks.length > 0;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue