Files
Signal-Desktop/ts/state/smart/StickerButton.tsx
Ken Powers 29de50c12a Stickers
Co-authored-by: scott@signal.org
Co-authored-by: ken@signal.org
2019-05-16 16:10:37 -07:00

49 lines
1.4 KiB
TypeScript

import { connect } from 'react-redux';
import { get } from 'lodash';
import { mapDispatchToProps } from '../actions';
import { StickerButton } from '../../components/stickers/StickerButton';
import { StateType } from '../reducer';
import { getIntl } from '../selectors/user';
import {
getInstalledStickerPacks,
getReceivedStickerPacks,
getRecentlyInstalledStickerPack,
getRecentStickers,
} from '../selectors/stickers';
const mapStateToProps = (state: StateType) => {
const receivedPacks = getReceivedStickerPacks(state);
const installedPacks = getInstalledStickerPacks(state);
const recentStickers = getRecentStickers(state);
const installedPack = getRecentlyInstalledStickerPack(state);
const showIntroduction = get(
state.items,
['showStickersIntroduction', 'value'],
false
);
const showPickerHint =
get(state.items, ['showStickerPickerHint', 'value'], false) &&
receivedPacks.length > 0;
return {
receivedPacks,
installedPack,
installedPacks,
recentStickers,
showIntroduction,
showPickerHint,
i18n: getIntl(state),
};
};
const smart = connect(mapStateToProps, {
...mapDispatchToProps,
clearShowIntroduction: () =>
mapDispatchToProps.removeItem('showStickersIntroduction'),
clearShowPickerHint: () =>
mapDispatchToProps.removeItem('showStickerPickerHint'),
});
export const SmartStickerButton = smart(StickerButton);