// 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 { ThemeType } 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'; import { NavSidebar } from './NavSidebar'; import type { WidthBreakpoint } from './_util'; import type { UnreadStats } from '../util/countUnreadStats'; export type PropsType = { i18n: LocalizerType; otherTabsUnreadStats: UnreadStats; hasFailedStorySends: boolean; hasPendingUpdate: boolean; navTabsCollapsed: boolean; myStories: Array; onBack: () => unknown; onDelete: (story: StoryViewType) => unknown; onForward: (storyId: string) => unknown; onSave: (story: StoryViewType) => unknown; onMediaPlaybackStart: () => void; onToggleNavTabsCollapse: (navTabsCollapsed: boolean) => void; queueStoryDownload: (storyId: string) => unknown; retryMessageSend: (messageId: string) => unknown; viewStory: ViewStoryActionCreatorType; hasViewReceiptSetting: boolean; preferredLeftPaneWidth: number; renderToastManager: (_: { containerWidthBreakpoint: WidthBreakpoint; }) => JSX.Element; savePreferredLeftPaneWidth: (preferredLeftPaneWidth: number) => void; theme: ThemeType; }; export function MyStories({ i18n, otherTabsUnreadStats, hasFailedStorySends, hasPendingUpdate, navTabsCollapsed, myStories, onBack, onDelete, onForward, onSave, queueStoryDownload, retryMessageSend, viewStory, hasViewReceiptSetting, onMediaPlaybackStart, onToggleNavTabsCollapse, preferredLeftPaneWidth, renderToastManager, savePreferredLeftPaneWidth, theme, }: PropsType): JSX.Element { const [confirmDeleteStory, setConfirmDeleteStory] = useState< StoryViewType | undefined >(); return ( <> {confirmDeleteStory && ( onDelete(confirmDeleteStory), style: 'negative', }, ]} i18n={i18n} onClose={() => setConfirmDeleteStory(undefined)} > {i18n('icu:MyStories__delete')} )}
{myStories.map(list => (
{list.stories.map(story => ( ))}
))}
{!myStories.length && (
{i18n('icu:Stories__list-empty')}
)}
); } type StorySentPropsType = Pick< PropsType, | 'hasViewReceiptSetting' | 'i18n' | 'onForward' | 'onSave' | 'queueStoryDownload' | 'retryMessageSend' | 'viewStory' | 'onMediaPlaybackStart' | 'theme' > & { setConfirmDeleteStory: (_: StoryViewType | undefined) => unknown; story: StoryViewType; }; function StorySent({ hasViewReceiptSetting, i18n, onForward, onSave, onMediaPlaybackStart, queueStoryDownload, retryMessageSend, setConfirmDeleteStory, story, theme, 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) && (
); }