Update selectedStoryData whenever its story changes
This commit is contained in:
parent
58aaf1d0e7
commit
c3bb3b152e
5 changed files with 53 additions and 19 deletions
|
@ -40,6 +40,11 @@ export const shouldShowStoriesView = createSelector(
|
|||
({ isShowingStoriesView }): boolean => isShowingStoriesView
|
||||
);
|
||||
|
||||
export const hasSelectedStoryData = createSelector(
|
||||
getStoriesState,
|
||||
({ selectedStoryData }): boolean => Boolean(selectedStoryData)
|
||||
);
|
||||
|
||||
export const getSelectedStoryData = createSelector(
|
||||
getStoriesState,
|
||||
({ selectedStoryData }): SelectedStoryDataType | undefined =>
|
||||
|
@ -370,3 +375,25 @@ export const getHasStoriesSelector = createSelector(
|
|||
: HasStories.Read;
|
||||
}
|
||||
);
|
||||
|
||||
export const getStoryByIdSelector = createSelector(
|
||||
getStoriesState,
|
||||
({ stories }) =>
|
||||
(
|
||||
conversationSelector: GetConversationByIdType,
|
||||
messageId: string
|
||||
):
|
||||
| { conversationStory: ConversationStoryType; storyView: StoryViewType }
|
||||
| undefined => {
|
||||
const story = stories.find(item => item.messageId === messageId);
|
||||
|
||||
if (!story) {
|
||||
return;
|
||||
}
|
||||
|
||||
return {
|
||||
conversationStory: getConversationStory(conversationSelector, story),
|
||||
storyView: getStoryView(conversationSelector, story),
|
||||
};
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue