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,
stickerSetAccessHash,
});
} else {
} else if (stickerSetShortName) {
loadStickers({
stickerSetShortName,
});
@ -134,7 +134,9 @@ export default memo(withGlobal(
return {
stickerSet: fromSticker
? selectStickerSet(global, fromSticker.stickerSetId)
: selectStickerSetByShortName(global, stickerSetShortName!),
: stickerSetShortName
? selectStickerSetByShortName(global, stickerSetShortName)
: undefined,
};
},
(setGlobal, actions): DispatchProps => pick(actions, [

View File

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