diff --git a/ts/components/Stories.tsx b/ts/components/Stories.tsx
index 4b87c6d7f2b0..462ce4a7223c 100644
--- a/ts/components/Stories.tsx
+++ b/ts/components/Stories.tsx
@@ -95,12 +95,12 @@ export const Stories = ({
diff --git a/ts/components/StoriesPane.tsx b/ts/components/StoriesPane.tsx
index 369feb59aa2f..172f3c9d0666 100644
--- a/ts/components/StoriesPane.tsx
+++ b/ts/components/StoriesPane.tsx
@@ -52,23 +52,23 @@ function getNewestStory(story: ConversationStoryType): StoryViewType {
export type PropsType = {
hiddenStories: Array;
i18n: LocalizerType;
- onBack: () => unknown;
onStoryClicked: (conversationId: string) => unknown;
openConversationInternal: (_: { conversationId: string }) => unknown;
queueStoryDownload: (storyId: string) => unknown;
stories: Array;
toggleHideStories: (conversationId: string) => unknown;
+ toggleStoriesView: () => unknown;
};
export const StoriesPane = ({
hiddenStories,
i18n,
- onBack,
onStoryClicked,
openConversationInternal,
queueStoryDownload,
stories,
toggleHideStories,
+ toggleStoriesView,
}: PropsType): JSX.Element => {
const [searchTerm, setSearchTerm] = useState('');
const [isShowingHiddenStories, setIsShowingHiddenStories] = useState(false);
@@ -89,7 +89,7 @@ export const StoriesPane = ({
@@ -119,11 +119,10 @@ export const StoriesPane = ({
onClick={() => {
onStoryClicked(story.conversationId);
}}
- onHideStory={() => {
- toggleHideStories(getNewestStory(story).sender.id);
- }}
+ onHideStory={toggleHideStories}
onGoToConversation={conversationId => {
openConversationInternal({ conversationId });
+ toggleStoriesView();
}}
queueStoryDownload={queueStoryDownload}
story={getNewestStory(story)}
@@ -149,11 +148,10 @@ export const StoriesPane = ({
onClick={() => {
onStoryClicked(story.conversationId);
}}
- onHideStory={() => {
- toggleHideStories(getNewestStory(story).sender.id);
- }}
+ onHideStory={toggleHideStories}
onGoToConversation={conversationId => {
openConversationInternal({ conversationId });
+ toggleStoriesView();
}}
queueStoryDownload={queueStoryDownload}
story={getNewestStory(story)}
diff --git a/ts/components/StoryListItem.stories.tsx b/ts/components/StoryListItem.stories.tsx
index 91513960a179..5371a0bb812b 100644
--- a/ts/components/StoryListItem.stories.tsx
+++ b/ts/components/StoryListItem.stories.tsx
@@ -23,6 +23,8 @@ function getDefaultProps(): PropsType {
return {
i18n,
onClick: action('onClick'),
+ onGoToConversation: action('onGoToConversation'),
+ onHideStory: action('onHideStory'),
queueStoryDownload: action('queueStoryDownload'),
story: {
messageId: '123',
diff --git a/ts/components/StoryListItem.tsx b/ts/components/StoryListItem.tsx
index b623df37e281..bb945ee18c83 100644
--- a/ts/components/StoryListItem.tsx
+++ b/ts/components/StoryListItem.tsx
@@ -62,8 +62,8 @@ export type PropsType = Pick<
> & {
i18n: LocalizerType;
onClick: () => unknown;
- onGoToConversation?: (conversationId: string) => unknown;
- onHideStory?: (conversationId: string) => unknown;
+ onGoToConversation: (conversationId: string) => unknown;
+ onHideStory: (conversationId: string) => unknown;
queueStoryDownload: (storyId: string) => unknown;
story: StoryViewType;
};
@@ -217,7 +217,7 @@ export const StoryListItem = ({
: i18n('StoryListItem__hide'),
onClick: () => {
if (isHidden) {
- onHideStory?.(sender.id);
+ onHideStory(sender.id);
} else {
setHasConfirmHideStory(true);
}
@@ -227,7 +227,7 @@ export const StoryListItem = ({
icon: 'StoryListItem__icon--chat',
label: i18n('StoryListItem__go-to-chat'),
onClick: () => {
- onGoToConversation?.(sender.id);
+ onGoToConversation(sender.id);
},
},
]}
@@ -242,7 +242,7 @@ export const StoryListItem = ({
onHideStory?.(sender.id),
+ action: () => onHideStory(sender.id),
style: 'affirmative',
text: i18n('StoryListItem__hide-modal--confirm'),
},
diff --git a/ts/components/StoryViewer.stories.tsx b/ts/components/StoryViewer.stories.tsx
index 9da966249d4a..1f98d2df27ee 100644
--- a/ts/components/StoryViewer.stories.tsx
+++ b/ts/components/StoryViewer.stories.tsx
@@ -27,6 +27,8 @@ function getDefaultProps(): PropsType {
loadStoryReplies: action('loadStoryReplies'),
markStoryRead: action('markStoryRead'),
onClose: action('onClose'),
+ onGoToConversation: action('onGoToConversation'),
+ onHideStory: action('onHideStory'),
onNextUserStories: action('onNextUserStories'),
onPrevUserStories: action('onPrevUserStories'),
onReactToStory: action('onReactToStory'),
diff --git a/ts/components/StoryViewer.tsx b/ts/components/StoryViewer.tsx
index ebb074b2d1eb..e201c6a7f3e8 100644
--- a/ts/components/StoryViewer.tsx
+++ b/ts/components/StoryViewer.tsx
@@ -12,6 +12,8 @@ import type { RenderEmojiPickerProps } from './conversation/ReactionPicker';
import type { ReplyStateType } from '../types/Stories';
import type { StoryViewType } from './StoryListItem';
import { Avatar, AvatarSize } from './Avatar';
+import { ConfirmationDialog } from './ConfirmationDialog';
+import { ContextMenuPopper } from './ContextMenu';
import { Intl } from './Intl';
import { MessageTimestamp } from './conversation/MessageTimestamp';
import { StoryImage } from './StoryImage';
@@ -41,6 +43,8 @@ export type PropsType = {
loadStoryReplies: (conversationId: string, messageId: string) => unknown;
markStoryRead: (mId: string) => unknown;
onClose: () => unknown;
+ onGoToConversation: (conversationId: string) => unknown;
+ onHideStory: (conversationId: string) => unknown;
onNextUserStories: () => unknown;
onPrevUserStories: () => unknown;
onSetSkinTone: (tone: number) => unknown;
@@ -76,6 +80,8 @@ export const StoryViewer = ({
loadStoryReplies,
markStoryRead,
onClose,
+ onGoToConversation,
+ onHideStory,
onNextUserStories,
onPrevUserStories,
onReactToStory,
@@ -96,15 +102,21 @@ export const StoryViewer = ({
const [currentStoryIndex, setCurrentStoryIndex] =
useState(selectedStoryIndex);
const [storyDuration, setStoryDuration] = useState();
+ const [isShowingContextMenu, setIsShowingContextMenu] = useState(false);
+ const [hasConfirmHideStory, setHasConfirmHideStory] = useState(false);
+ const [referenceElement, setReferenceElement] =
+ useState(null);
const visibleStory = stories[currentStoryIndex];
- const { attachment, canReply, messageId, timestamp } = visibleStory;
+ const { attachment, canReply, isHidden, messageId, timestamp } = visibleStory;
const {
acceptedMessageRequest,
avatarPath,
color,
isMe,
+ id,
+ firstName,
name,
profileName,
sharedGroupNames,
@@ -226,13 +238,19 @@ export const StoryViewer = ({
};
}, [currentStoryIndex, spring, storyDuration]);
+ const shouldPauseViewing =
+ hasConfirmHideStory ||
+ hasExpandedCaption ||
+ hasReplyModal ||
+ isShowingContextMenu;
+
useEffect(() => {
- if (hasReplyModal || hasExpandedCaption) {
+ if (shouldPauseViewing) {
spring.pause();
} else {
spring.resume();
}
- }, [hasExpandedCaption, hasReplyModal, spring]);
+ }, [shouldPauseViewing, spring]);
useEffect(() => {
markStoryRead(messageId);
@@ -248,7 +266,7 @@ export const StoryViewer = ({
.map(story => story.messageId);
}, [stories]);
useEffect(() => {
- storiesToDownload.forEach(id => queueStoryDownload(id));
+ storiesToDownload.forEach(storyId => queueStoryDownload(storyId));
}, [queueStoryDownload, storiesToDownload]);
const navigateStories = useCallback(
@@ -452,6 +470,8 @@ export const StoryViewer = ({