Sticker pack download: require just one successful sticker download
This commit is contained in:
parent
3620309f22
commit
5a7196e464
5 changed files with 159 additions and 57 deletions
|
@ -28,6 +28,10 @@ export type OwnProps = {
|
|||
export type Props = OwnProps;
|
||||
|
||||
function renderBody({ pack, i18n }: Props) {
|
||||
if (!pack) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (pack && pack.status === 'error') {
|
||||
return (
|
||||
<div className="module-sticker-manager__preview-modal__container__error">
|
||||
|
@ -36,7 +40,7 @@ function renderBody({ pack, i18n }: Props) {
|
|||
);
|
||||
}
|
||||
|
||||
if (!pack || pack.stickerCount === 0 || !isNumber(pack.stickerCount)) {
|
||||
if (pack.stickerCount === 0 || !isNumber(pack.stickerCount)) {
|
||||
return <Spinner svgSize="normal" />;
|
||||
}
|
||||
|
||||
|
@ -54,15 +58,16 @@ function renderBody({ pack, i18n }: Props) {
|
|||
/>
|
||||
</div>
|
||||
))}
|
||||
{range(pack.stickerCount - pack.stickers.length).map(i => (
|
||||
<div
|
||||
key={`placeholder-${i}`}
|
||||
className={classNames(
|
||||
'module-sticker-manager__preview-modal__container__sticker-grid__cell',
|
||||
'module-sticker-manager__preview-modal__container__sticker-grid__cell--placeholder'
|
||||
)}
|
||||
/>
|
||||
))}
|
||||
{pack.status === 'pending' &&
|
||||
range(pack.stickerCount - pack.stickers.length).map(i => (
|
||||
<div
|
||||
key={`placeholder-${i}`}
|
||||
className={classNames(
|
||||
'module-sticker-manager__preview-modal__container__sticker-grid__cell',
|
||||
'module-sticker-manager__preview-modal__container__sticker-grid__cell--placeholder'
|
||||
)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -110,6 +115,12 @@ export const StickerPreviewModal = React.memo((props: Props) => {
|
|||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!pack) {
|
||||
onClose();
|
||||
}
|
||||
}, [pack, onClose]);
|
||||
|
||||
const isInstalled = Boolean(pack && pack.status === 'installed');
|
||||
const handleToggleInstall = React.useCallback(() => {
|
||||
if (!pack) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue