signal-desktop/ts/state/smart/StickerPreviewModal.tsx
Ken Powers be5d0837f8 Support additional sticker states
Co-authored-by: scott@signal.org
Co-authored-by: ken@signal.org
2019-05-29 11:01:32 -07:00

38 lines
1 KiB
TypeScript

import { connect } from 'react-redux';
import { mapDispatchToProps } from '../actions';
import { StickerPreviewModal } from '../../components/stickers/StickerPreviewModal';
import { StateType } from '../reducer';
import { getIntl, getStickersPath, getTempPath } from '../selectors/user';
import {
getBlessedPacks,
getPacks,
translatePackFromDB,
} from '../selectors/stickers';
type ExternalProps = {
packId: string;
readonly onClose: () => unknown;
};
const mapStateToProps = (state: StateType, props: ExternalProps) => {
const { packId } = props;
const stickersPath = getStickersPath(state);
const tempPath = getTempPath(state);
const packs = getPacks(state);
const blessedPacks = getBlessedPacks(state);
const pack = packs[packId];
return {
...props,
pack: pack
? translatePackFromDB(pack, packs, blessedPacks, stickersPath, tempPath)
: undefined,
i18n: getIntl(state),
};
};
const smart = connect(mapStateToProps, mapDispatchToProps);
export const SmartStickerPreviewModal = smart(StickerPreviewModal);