Support additional sticker states

Co-authored-by: scott@signal.org
Co-authored-by: ken@signal.org
This commit is contained in:
Ken Powers 2019-05-23 18:27:42 -07:00 committed by Scott Nonnenberg
parent 41880cfe66
commit be5d0837f8
35 changed files with 925 additions and 249 deletions

View file

@ -3,7 +3,7 @@ import { mapDispatchToProps } from '../actions';
import { StickerPreviewModal } from '../../components/stickers/StickerPreviewModal';
import { StateType } from '../reducer';
import { getIntl, getStickersPath } from '../selectors/user';
import { getIntl, getStickersPath, getTempPath } from '../selectors/user';
import {
getBlessedPacks,
getPacks,
@ -18,33 +18,17 @@ type ExternalProps = {
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];
if (!pack) {
throw new Error(`Cannot find pack ${packId}`);
}
const translated = translatePackFromDB(
pack,
packs,
blessedPacks,
stickersPath
);
return {
...props,
pack: {
...translated,
cover: translated.cover
? translated.cover
: {
id: 0,
url: 'nonexistent',
packId,
emoji: 'WTF',
},
},
pack: pack
? translatePackFromDB(pack, packs, blessedPacks, stickersPath, tempPath)
: undefined,
i18n: getIntl(state),
};
};