diff --git a/js/storage.js b/js/storage.js index bea60767dd..2e7d061117 100644 --- a/js/storage.js +++ b/js/storage.js @@ -87,7 +87,13 @@ } 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() { diff --git a/ts/components/emoji/lib.ts b/ts/components/emoji/lib.ts index 064f765a77..8e12604aab 100644 --- a/ts/components/emoji/lib.ts +++ b/ts/components/emoji/lib.ts @@ -112,6 +112,10 @@ export const dataByCategory = mapValues( arr => sortBy(arr, 'sort_order') ); +export function isShortNameValid(shortName: string) { + return Boolean(dataByShortName[shortName]); +} + export function getSheetCoordinates( shortName: keyof typeof dataByShortName, skinTone?: SkinToneKey | number diff --git a/ts/state/smart/EmojiButton.tsx b/ts/state/smart/EmojiButton.tsx index 4853a12842..eb5d3e135a 100644 --- a/ts/state/smart/EmojiButton.tsx +++ b/ts/state/smart/EmojiButton.tsx @@ -5,6 +5,7 @@ import { mapDispatchToProps } from '../actions'; import { EmojiButton, Props } from '../../components/emoji/EmojiButton'; import { StateType } from '../reducer'; +import { isShortNameValid } from '../../components/emoji/lib'; import { getIntl } from '../selectors/user'; const mapStateToProps = (state: StateType) => { @@ -12,8 +13,8 @@ const mapStateToProps = (state: StateType) => { return { i18n: getIntl(state), - recentEmojis: recents, - skinTone: get(state, ['items', 'skinTone', 'value'], 0), + recentEmojis: recents.filter(isShortNameValid), + skinTone: get(state, ['items', 'skinTone'], 0), }; }; diff --git a/ts/state/smart/StickerButton.tsx b/ts/state/smart/StickerButton.tsx index d41c9c34ed..ea3914a025 100644 --- a/ts/state/smart/StickerButton.tsx +++ b/ts/state/smart/StickerButton.tsx @@ -24,11 +24,11 @@ const mapStateToProps = (state: StateType) => { const installedPack = getRecentlyInstalledStickerPack(state); const showIntroduction = get( state.items, - ['showStickersIntroduction', 'value'], + ['showStickersIntroduction'], false ); const showPickerHint = - get(state.items, ['showStickerPickerHint', 'value'], false) && + get(state.items, ['showStickerPickerHint'], false) && receivedPacks.length > 0; return {