Sticker Set Modal: Prevent exception when missing sticker set

This commit is contained in:
Alexander Zinchuk 2021-08-12 15:36:33 +03:00
parent 5a23d30a21
commit fc61b38b88
2 changed files with 10 additions and 4 deletions

View File

@ -61,7 +61,7 @@ const StickerSetModal: FC<OwnProps & StateProps & DispatchProps> = ({
stickerSetId, stickerSetId,
stickerSetAccessHash, stickerSetAccessHash,
}); });
} else { } else if (stickerSetShortName) {
loadStickers({ loadStickers({
stickerSetShortName, stickerSetShortName,
}); });
@ -134,7 +134,9 @@ export default memo(withGlobal(
return { return {
stickerSet: fromSticker stickerSet: fromSticker
? selectStickerSet(global, fromSticker.stickerSetId) ? selectStickerSet(global, fromSticker.stickerSetId)
: selectStickerSetByShortName(global, stickerSetShortName!), : stickerSetShortName
? selectStickerSetByShortName(global, stickerSetShortName)
: undefined,
}; };
}, },
(setGlobal, actions): DispatchProps => pick(actions, [ (setGlobal, actions): DispatchProps => pick(actions, [

View File

@ -214,6 +214,10 @@ const Main: FC<StateProps & DispatchProps> = ({
updateIcon(false); updateIcon(false);
}, [updateIsOnline]); }, [updateIsOnline]);
const handleStickerSetModalClose = useCallback(() => {
openStickerSetShortName({ stickerSetShortName: undefined });
}, [openStickerSetShortName]);
// Online status and browser tab indicators // Online status and browser tab indicators
useBackgroundMode(handleBlur, handleFocus); useBackgroundMode(handleBlur, handleFocus);
useBeforeUnload(handleBlur); useBeforeUnload(handleBlur);
@ -236,8 +240,8 @@ const Main: FC<StateProps & DispatchProps> = ({
<SafeLinkModal url={safeLinkModalUrl} /> <SafeLinkModal url={safeLinkModalUrl} />
<HistoryCalendar isOpen={isHistoryCalendarOpen} /> <HistoryCalendar isOpen={isHistoryCalendarOpen} />
<StickerSetModal <StickerSetModal
isOpen={!!openedStickerSetShortName} isOpen={Boolean(openedStickerSetShortName)}
onClose={() => openStickerSetShortName({ stickerSetShortName: undefined })} onClose={handleStickerSetModalClose}
stickerSetShortName={openedStickerSetShortName} stickerSetShortName={openedStickerSetShortName}
/> />
</div> </div>