Autoplay the hidden stories section

This commit is contained in:
Josh Perez 2022-09-22 14:56:39 -04:00 committed by GitHub
parent 7edb9edfe1
commit 94ef800e33
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 5 deletions

View file

@ -326,6 +326,7 @@ export const StoryViewer = ({
const canFreelyNavigateStories =
storyViewMode === StoryViewModeType.All ||
storyViewMode === StoryViewModeType.Hidden ||
storyViewMode === StoryViewModeType.Unread;
const canNavigateLeft =

View file

@ -814,6 +814,21 @@ const viewUserStories: ViewUserStoriesActionCreatorType = ({
const story = storiesByConversationId[currentIndex];
const hiddenConversationIds = new Set(
getHideStoryConversationIds(getState())
);
let inferredStoryViewMode: StoryViewModeType;
if (storyViewMode) {
inferredStoryViewMode = storyViewMode;
} else if (hiddenConversationIds.has(conversationId)) {
inferredStoryViewMode = StoryViewModeType.Hidden;
} else if (hasUnread) {
inferredStoryViewMode = StoryViewModeType.Unread;
} else {
inferredStoryViewMode = StoryViewModeType.All;
}
dispatch({
type: VIEW_STORY,
payload: {
@ -821,9 +836,7 @@ const viewUserStories: ViewUserStoriesActionCreatorType = ({
messageId: story.messageId,
numStories,
shouldShowDetailsModal,
storyViewMode:
storyViewMode ||
(hasUnread ? StoryViewModeType.Unread : StoryViewModeType.All),
storyViewMode: inferredStoryViewMode,
},
});
};
@ -1008,7 +1021,11 @@ const viewStory: ViewStoryActionCreatorType = (
}
}
const conversationStories = getStories(state).stories;
const storiesSelectorState = getStories(state);
const conversationStories =
storyViewMode === StoryViewModeType.Hidden
? storiesSelectorState.hiddenStories
: storiesSelectorState.stories;
const conversationStoryIndex = conversationStories.findIndex(
item => item.conversationId === story.conversationId
);

View file

@ -405,7 +405,9 @@ export const getStories = createSelector(
});
return {
hiddenStories: Array.from(hiddenStoriesById.values()),
hiddenStories: Array.from(hiddenStoriesById.values()).sort(
sortByRecencyAndUnread
),
myStories: Array.from(myStoriesById.values()).sort(sortMyStories),
stories: Array.from(storiesById.values()).sort(sortByRecencyAndUnread),
};

View file

@ -116,6 +116,7 @@ export enum StoryViewDirectionType {
// User = All of a user's stories
export enum StoryViewModeType {
All = 'All',
Hidden = 'Hidden',
Single = 'Single',
Unread = 'Unread',
User = 'User',