Skip to content

Commit

Permalink
Gracefully close the story viewer when we cannot find story
Browse files Browse the repository at this point in the history
Co-authored-by: Josh Perez <60019601+josh-signal@users.noreply.github.com>
  • Loading branch information
automated-signal and josh-signal committed Oct 25, 2022
1 parent 7a672a9 commit 2692a16
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions ts/state/smart/StoryViewer.tsx
Expand Up @@ -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);
Expand All @@ -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}
Expand Down

0 comments on commit 2692a16

Please sign in to comment.