Close viewer after viewing a single story

This commit is contained in:
Josh Perez 2022-10-26 21:03:43 -04:00 committed by GitHub
parent 5ccfabeb0c
commit 42362a2772
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View file

@ -842,6 +842,15 @@ const viewStory: ViewStoryActionCreatorType = (
return;
}
if (storyViewMode === StoryViewModeType.Single) {
// Close the viewer we were just looking at a single story.
dispatch({
type: VIEW_STORY,
payload: undefined,
});
return;
}
// When paging through all sent stories
// Note the order is reversed[1][2] here because we sort the stories by
// recency in descending order but the story viewer plays them in

View file

@ -130,6 +130,21 @@ describe('both/state/ducks/stories', () => {
});
});
it('closes the viewer when viewing a single story', () => {
const dispatch = sinon.spy();
viewStory({
storyId: UUID.generate().toString(),
storyViewMode: StoryViewModeType.Single,
viewDirection: StoryViewDirectionType.Next,
})(dispatch, getEmptyRootState, null);
sinon.assert.calledWith(dispatch, {
type: 'stories/VIEW_STORY',
payload: undefined,
});
});
it('does not find a story', () => {
const dispatch = sinon.spy();
viewStory({