// Copyright 2022 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React, { useState } from 'react'; import type { MyStoryType, StoryViewType } from '../types/Stories'; import { ResolvedSendStatus, StoryViewTargetType, StoryViewModeType, } from '../types/Stories'; import type { LocalizerType } from '../types/Util'; import type { ViewStoryActionCreatorType } from '../state/ducks/stories'; import { ConfirmationDialog } from './ConfirmationDialog'; import { ContextMenu } from './ContextMenu'; import { MessageTimestamp } from './conversation/MessageTimestamp'; import { StoryDistributionListName } from './StoryDistributionListName'; import { StoryImage } from './StoryImage'; import { Theme } from '../util/theme'; import { resolveStorySendStatus } from '../util/resolveStorySendStatus'; import { useRetryStorySend } from '../hooks/useRetryStorySend'; export type PropsType = { i18n: LocalizerType; myStories: Array; onBack: () => unknown; onDelete: (story: StoryViewType) => unknown; onForward: (storyId: string) => unknown; onSave: (story: StoryViewType) => unknown; queueStoryDownload: (storyId: string) => unknown; retrySend: (messageId: string) => unknown; viewStory: ViewStoryActionCreatorType; hasViewReceiptSetting: boolean; }; export function MyStories({ i18n, myStories, onBack, onDelete, onForward, onSave, queueStoryDownload, retrySend, viewStory, hasViewReceiptSetting, }: PropsType): JSX.Element { const [confirmDeleteStory, setConfirmDeleteStory] = useState< StoryViewType | undefined >(); return ( <> {confirmDeleteStory && ( onDelete(confirmDeleteStory), style: 'negative', }, ]} i18n={i18n} onClose={() => setConfirmDeleteStory(undefined)} > {i18n('MyStories__delete')} )}
{myStories.map(list => (
{list.stories.map(story => ( ))}
))}
{!myStories.length && (
{i18n('Stories__list-empty')}
)} ); } type StorySentPropsType = Pick< PropsType, | 'hasViewReceiptSetting' | 'i18n' | 'onForward' | 'onSave' | 'queueStoryDownload' | 'retrySend' | 'viewStory' > & { setConfirmDeleteStory: (_: StoryViewType | undefined) => unknown; story: StoryViewType; }; function StorySent({ hasViewReceiptSetting, i18n, onForward, onSave, queueStoryDownload, retrySend, setConfirmDeleteStory, story, viewStory, }: StorySentPropsType): JSX.Element { const sendStatus = resolveStorySendStatus(story.sendState ?? []); const { renderAlert, setWasManuallyRetried, wasManuallyRetried } = useRetryStorySend(i18n, sendStatus); return (
{renderAlert()} {story.attachment && (story.attachment.path || story.attachment.data) && (
); }