2022-02-25 23:59:43 +00:00
|
|
|
// Copyright 2019-2022 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2019-05-16 22:32:11 +00:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { mapDispatchToProps } from '../actions';
|
|
|
|
import { StickerPreviewModal } from '../../components/stickers/StickerPreviewModal';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { StateType } from '../reducer';
|
2019-05-16 22:32:11 +00:00
|
|
|
|
2019-05-24 01:27:42 +00:00
|
|
|
import { getIntl, getStickersPath, getTempPath } from '../selectors/user';
|
2019-05-16 22:32:11 +00:00
|
|
|
import {
|
|
|
|
getBlessedPacks,
|
|
|
|
getPacks,
|
|
|
|
translatePackFromDB,
|
|
|
|
} from '../selectors/stickers';
|
|
|
|
|
2022-02-25 23:59:43 +00:00
|
|
|
export type ExternalProps = {
|
2019-05-16 22:32:11 +00:00
|
|
|
packId: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
const mapStateToProps = (state: StateType, props: ExternalProps) => {
|
|
|
|
const { packId } = props;
|
|
|
|
const stickersPath = getStickersPath(state);
|
2019-05-24 01:27:42 +00:00
|
|
|
const tempPath = getTempPath(state);
|
|
|
|
|
2019-05-16 22:32:11 +00:00
|
|
|
const packs = getPacks(state);
|
|
|
|
const blessedPacks = getBlessedPacks(state);
|
|
|
|
const pack = packs[packId];
|
|
|
|
|
|
|
|
return {
|
|
|
|
...props,
|
2019-05-24 01:27:42 +00:00
|
|
|
pack: pack
|
|
|
|
? translatePackFromDB(pack, packs, blessedPacks, stickersPath, tempPath)
|
|
|
|
: undefined,
|
2019-05-16 22:32:11 +00:00
|
|
|
i18n: getIntl(state),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const smart = connect(mapStateToProps, mapDispatchToProps);
|
|
|
|
|
|
|
|
export const SmartStickerPreviewModal = smart(StickerPreviewModal);
|