2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2019 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
import React, { memo } from 'react';
|
|
|
|
import { useSelector } from 'react-redux';
|
2019-05-16 22:32:11 +00:00
|
|
|
import { StickerPreviewModal } from '../../components/stickers/StickerPreviewModal';
|
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';
|
2024-03-13 20:44:13 +00:00
|
|
|
import { useStickersActions } from '../ducks/stickers';
|
|
|
|
import { useGlobalModalActions } from '../ducks/globalModals';
|
2019-05-16 22:32:11 +00:00
|
|
|
|
2022-02-25 23:59:43 +00:00
|
|
|
export type ExternalProps = {
|
2019-05-16 22:32:11 +00:00
|
|
|
packId: string;
|
|
|
|
};
|
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
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}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
});
|