Update selectedStoryData whenever its story changes

This commit is contained in:
Josh Perez 2022-07-29 16:22:55 -04:00 committed by GitHub
parent 58aaf1d0e7
commit c3bb3b152e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 53 additions and 19 deletions

View file

@ -20,10 +20,9 @@ import {
import { getIntl } from '../selectors/user';
import { getPreferredBadgeSelector } from '../selectors/badges';
import {
getConversationStory,
getSelectedStoryData,
getStoryReplies,
getStoryView,
getStoryByIdSelector,
} from '../selectors/stories';
import { renderEmojiPicker } from './renderEmojiPicker';
import { strictAssert } from '../../util/assert';
@ -57,11 +56,18 @@ export function SmartStoryViewer(): JSX.Element | null {
getConversationSelector
);
const storyView = getStoryView(conversationSelector, selectedStoryData.story);
const conversationStory = getConversationStory(
const getStoryById = useSelector(getStoryByIdSelector);
const storyInfo = getStoryById(
conversationSelector,
selectedStoryData.story
selectedStoryData.messageId
);
strictAssert(
storyInfo,
'StoryViewer: selected story does not exist in stories'
);
const { conversationStory, storyView } = storyInfo;
const storyViewMode = useSelector<StateType, StoryViewModeType | undefined>(
state => state.stories.storyViewMode
);