// 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 type { LocalizerType } from '../types/Util'; import type { ViewStoryActionCreatorType } from '../state/ducks/stories'; import { ConfirmationDialog } from './ConfirmationDialog'; import { ContextMenu } from './ContextMenu'; import { StoryViewModeType } from '../types/Stories'; import { MessageTimestamp } from './conversation/MessageTimestamp'; import { StoryDistributionListName } from './StoryDistributionListName'; import { StoryImage } from './StoryImage'; import { Theme } from '../util/theme'; 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; viewStory: ViewStoryActionCreatorType; }; export const MyStories = ({ i18n, myStories, onBack, onDelete, onForward, onSave, queueStoryDownload, viewStory, }: 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 => (
{story.attachment && ( )}
{story.views === 1 ? i18n('MyStories__views--singular', [String(story.views)]) : i18n('MyStories__views--plural', [ String(story.views || 0), ])}
))}
))}
{!myStories.length && (
{i18n('Stories__list-empty')}
)} ); };