Filtered stories to self to fix StoryViewer progress lines

This commit is contained in:
Alvaro 2022-11-29 15:19:50 -07:00 committed by GitHub
parent 2d620c380e
commit b246b3d8af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -735,8 +735,15 @@ const getSelectedStoryDataForDistributionListId = (
const getSelectedStoryDataForConversationId = ( const getSelectedStoryDataForConversationId = (
dispatch: ThunkDispatch<RootStateType, unknown, NoopActionType>, dispatch: ThunkDispatch<RootStateType, unknown, NoopActionType>,
getState: () => RootStateType, getState: () => RootStateType,
conversationId: string, {
selectedStoryId?: string conversationId,
onlyFromSelf,
selectedStoryId,
}: {
conversationId: string;
onlyFromSelf: boolean;
selectedStoryId?: string;
}
): { ): {
currentIndex: number; currentIndex: number;
hasUnread: boolean; hasUnread: boolean;
@ -746,8 +753,12 @@ const getSelectedStoryDataForConversationId = (
const state = getState(); const state = getState();
const { stories } = state.stories; const { stories } = state.stories;
const ourUuid = window.storage.user.getCheckedUuid().toString();
const storiesByConversationId = stories.filter( const storiesByConversationId = stories.filter(
item => item.conversationId === conversationId && !item.deletedForEveryone item =>
item.conversationId === conversationId &&
!item.deletedForEveryone &&
(!onlyFromSelf || item.sourceUuid === ourUuid)
); );
// Find the index of the storyId provided, or if none provided then find the // Find the index of the storyId provided, or if none provided then find the
@ -802,7 +813,10 @@ const viewUserStories: ViewUserStoriesActionCreatorType = ({
}): ThunkAction<void, RootStateType, unknown, ViewStoryActionType> => { }): ThunkAction<void, RootStateType, unknown, ViewStoryActionType> => {
return (dispatch, getState) => { return (dispatch, getState) => {
const { currentIndex, hasUnread, numStories, storiesByConversationId } = const { currentIndex, hasUnread, numStories, storiesByConversationId } =
getSelectedStoryDataForConversationId(dispatch, getState, conversationId); getSelectedStoryDataForConversationId(dispatch, getState, {
conversationId,
onlyFromSelf: false,
});
const story = storiesByConversationId[currentIndex]; const story = storiesByConversationId[currentIndex];
const state = getState(); const state = getState();
@ -921,12 +935,11 @@ const viewStory: ViewStoryActionCreatorType = (
story.storyDistributionListId, story.storyDistributionListId,
storyId storyId
) )
: getSelectedStoryDataForConversationId( : getSelectedStoryDataForConversationId(dispatch, getState, {
dispatch, conversationId: story.conversationId,
getState, onlyFromSelf: storyViewMode === StoryViewModeType.MyStories,
story.conversationId, selectedStoryId: storyId,
storyId });
);
// Go directly to the storyId selected // Go directly to the storyId selected
if (!viewDirection) { if (!viewDirection) {
@ -1123,7 +1136,10 @@ const viewStory: ViewStoryActionCreatorType = (
const nextSelectedStoryData = getSelectedStoryDataForConversationId( const nextSelectedStoryData = getSelectedStoryDataForConversationId(
dispatch, dispatch,
getState, getState,
nextUnreadConversationId {
conversationId: nextUnreadConversationId,
onlyFromSelf: false,
}
); );
dispatch({ dispatch({
@ -1182,7 +1198,10 @@ const viewStory: ViewStoryActionCreatorType = (
const nextSelectedStoryData = getSelectedStoryDataForConversationId( const nextSelectedStoryData = getSelectedStoryDataForConversationId(
dispatch, dispatch,
getState, getState,
conversationStory.conversationId {
conversationId: conversationStory.conversationId,
onlyFromSelf: false,
}
); );
dispatch({ dispatch({
@ -1217,7 +1236,10 @@ const viewStory: ViewStoryActionCreatorType = (
const nextSelectedStoryData = getSelectedStoryDataForConversationId( const nextSelectedStoryData = getSelectedStoryDataForConversationId(
dispatch, dispatch,
getState, getState,
conversationStory.conversationId {
conversationId: conversationStory.conversationId,
onlyFromSelf: false,
}
); );
dispatch({ dispatch({