Gracefully close the story viewer when we cannot find story

This commit is contained in:
Josh Perez 2022-10-24 13:45:51 -04:00 committed by GitHub
parent 471a9e2e98
commit e79380b37c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -59,16 +59,6 @@ export function SmartStoryViewer(): JSX.Element | null {
const getStoryById = useSelector(getStoryByIdSelector);
const storyInfo = getStoryById(
conversationSelector,
selectedStoryData.messageId
);
strictAssert(
storyInfo,
'StoryViewer: selected story does not exist in stories'
);
const { conversationStory, distributionList, storyView } = storyInfo;
const recentEmojis = useRecentEmojis();
const skinTone = useSelector<StateType, number>(getEmojiSkinTone);
const replyState = useSelector(getStoryReplies);
@ -81,6 +71,17 @@ export function SmartStoryViewer(): JSX.Element | null {
getHasReadReceiptSetting
);
const storyInfo = getStoryById(
conversationSelector,
selectedStoryData.messageId
);
if (!storyInfo) {
return null;
}
const { conversationStory, distributionList, storyView } = storyInfo;
return (
<StoryViewer
currentIndex={selectedStoryData.currentIndex}