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

@ -9,6 +9,8 @@ export type OwnProps = {
readonly installedPacks: ReadonlyArray<StickerPackType>;
readonly receivedPacks: ReadonlyArray<StickerPackType>;
readonly blessedPacks: ReadonlyArray<StickerPackType>;
readonly knownPacks?: ReadonlyArray<StickerPackType>;
readonly downloadStickerPack: (packId: string, packKey: string) => unknown;
readonly installStickerPack: (packId: string, packKey: string) => unknown;
readonly uninstallStickerPack: (packId: string, packKey: string) => unknown;
readonly i18n: LocalizerType;
@ -20,7 +22,9 @@ export const StickerManager = React.memo(
({
installedPacks,
receivedPacks,
knownPacks,
blessedPacks,
downloadStickerPack,
installStickerPack,
uninstallStickerPack,
i18n,
@ -30,6 +34,15 @@ export const StickerManager = React.memo(
setPackToPreview,
] = React.useState<StickerPackType | null>(null);
React.useEffect(() => {
if (!knownPacks) {
return;
}
knownPacks.forEach(pack => {
downloadStickerPack(pack.id, pack.key);
});
}, []);
const clearPackToPreview = React.useCallback(
() => {
setPackToPreview(null);
@ -51,6 +64,7 @@ export const StickerManager = React.memo(
i18n={i18n}
pack={packToPreview}
onClose={clearPackToPreview}
downloadStickerPack={downloadStickerPack}
installStickerPack={installStickerPack}
uninstallStickerPack={uninstallStickerPack}
/>