// Copyright 2021 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React, { ReactChild, ReactNode, useState } from 'react'; import moment from 'moment'; import { Modal } from './Modal'; import { Intl, IntlComponentsType } from './Intl'; import { Emojify } from './conversation/Emojify'; import type { LocalizerType, RenderTextCallbackType } from '../types/Util'; export type PropsType = { i18n: LocalizerType; }; type ReleaseNotesType = { date: Date; version: string; features: Array<{ key: string; components: IntlComponentsType }>; }; const renderText: RenderTextCallbackType = ({ key, text }) => ( ); export const WhatsNew = ({ i18n }: PropsType): JSX.Element => { const [releaseNotes, setReleaseNotes] = useState< ReleaseNotesType | undefined >(); const viewReleaseNotes = () => { setReleaseNotes({ date: new Date(window.getBuildCreation?.() || Date.now()), version: window.getVersion(), features: [{ key: 'WhatsNew__v5.20', components: undefined }], }); }; let modalNode: ReactNode; if (releaseNotes) { let contentNode: ReactChild; if (releaseNotes.features.length === 1) { const { key, components } = releaseNotes.features[0]; contentNode = (

); } else { contentNode = ( ); } modalNode = ( setReleaseNotes(undefined)} title={i18n('WhatsNew__modal-title')} > <> {moment(releaseNotes.date).format('LL')} ·{' '} {releaseNotes.version} {contentNode} ); } return ( <> {modalNode} {i18n('viewReleaseNotes')} , ]} /> ); };