signal-desktop/ts/state/smart/StickerPreviewModal.tsx
Jamie Kyle 27b55e472d
Refactor smart components
Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
2024-03-13 13:44:13 -07:00

48 lines
1.5 KiB
TypeScript

// Copyright 2019 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React, { memo } from 'react';
import { useSelector } from 'react-redux';
import { StickerPreviewModal } from '../../components/stickers/StickerPreviewModal';
import { getIntl, getStickersPath, getTempPath } from '../selectors/user';
import {
getBlessedPacks,
getPacks,
translatePackFromDB,
} from '../selectors/stickers';
import { useStickersActions } from '../ducks/stickers';
import { useGlobalModalActions } from '../ducks/globalModals';
export type ExternalProps = {
packId: string;
};
export const SmartStickerPreviewModal = memo(function SmartStickerPreviewModal({
packId,
}: ExternalProps) {
const i18n = useSelector(getIntl);
const packs = useSelector(getPacks);
const blessedPacks = useSelector(getBlessedPacks);
const stickersPath = useSelector(getStickersPath);
const tempPath = useSelector(getTempPath);
const { downloadStickerPack, installStickerPack, uninstallStickerPack } =
useStickersActions();
const { closeStickerPackPreview } = useGlobalModalActions();
const packDb = packs[packId];
const pack = packDb
? translatePackFromDB(packDb, packs, blessedPacks, stickersPath, tempPath)
: undefined;
return (
<StickerPreviewModal
closeStickerPackPreview={closeStickerPackPreview}
downloadStickerPack={downloadStickerPack}
i18n={i18n}
installStickerPack={installStickerPack}
pack={pack}
uninstallStickerPack={uninstallStickerPack}
/>
);
});