2022-01-04 23:44:26 +00:00
|
|
|
// Copyright 2021-2022 Signal Messenger, LLC
|
2021-10-23 00:41:45 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { ReactChild } from 'react';
|
|
|
|
import React from 'react';
|
2021-10-23 00:41:45 +00:00
|
|
|
import moment from 'moment';
|
|
|
|
|
|
|
|
import { Modal } from './Modal';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { IntlComponentsType } from './Intl';
|
|
|
|
import { Intl } from './Intl';
|
2021-10-23 00:41:45 +00:00
|
|
|
import { Emojify } from './conversation/Emojify';
|
|
|
|
import type { LocalizerType, RenderTextCallbackType } from '../types/Util';
|
|
|
|
|
|
|
|
export type PropsType = {
|
|
|
|
hideWhatsNewModal: () => unknown;
|
|
|
|
i18n: LocalizerType;
|
|
|
|
};
|
|
|
|
|
|
|
|
type ReleaseNotesType = {
|
|
|
|
date: Date;
|
|
|
|
version: string;
|
|
|
|
features: Array<{ key: string; components: IntlComponentsType }>;
|
|
|
|
};
|
|
|
|
|
|
|
|
const renderText: RenderTextCallbackType = ({ key, text }) => (
|
|
|
|
<Emojify key={key} text={text} />
|
|
|
|
);
|
|
|
|
|
|
|
|
const releaseNotes: ReleaseNotesType = {
|
|
|
|
date: new Date(window.getBuildCreation?.() || Date.now()),
|
2021-12-02 16:51:04 +00:00
|
|
|
version: window.getVersion?.(),
|
2022-02-02 21:15:54 +00:00
|
|
|
features: [
|
2022-02-10 22:07:10 +00:00
|
|
|
{ key: 'WhatsNew__v5.32--1', components: undefined },
|
|
|
|
{ key: 'WhatsNew__v5.32--2', components: undefined },
|
2022-02-02 21:15:54 +00:00
|
|
|
],
|
2021-10-23 00:41:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const WhatsNewModal = ({
|
|
|
|
i18n,
|
|
|
|
hideWhatsNewModal,
|
|
|
|
}: PropsType): JSX.Element => {
|
|
|
|
let contentNode: ReactChild;
|
|
|
|
|
|
|
|
if (releaseNotes.features.length === 1) {
|
|
|
|
const { key, components } = releaseNotes.features[0];
|
|
|
|
contentNode = (
|
|
|
|
<p>
|
|
|
|
<Intl
|
|
|
|
i18n={i18n}
|
|
|
|
id={key}
|
|
|
|
renderText={renderText}
|
|
|
|
components={components}
|
|
|
|
/>
|
|
|
|
</p>
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
contentNode = (
|
|
|
|
<ul>
|
|
|
|
{releaseNotes.features.map(({ key, components }) => (
|
|
|
|
<li key={key}>
|
|
|
|
<Intl
|
|
|
|
i18n={i18n}
|
|
|
|
id={key}
|
|
|
|
renderText={renderText}
|
|
|
|
components={components}
|
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Modal
|
|
|
|
hasXButton
|
|
|
|
i18n={i18n}
|
|
|
|
onClose={hideWhatsNewModal}
|
|
|
|
title={i18n('WhatsNew__modal-title')}
|
|
|
|
>
|
|
|
|
<>
|
|
|
|
<span>
|
|
|
|
{moment(releaseNotes.date).format('LL')} ·{' '}
|
|
|
|
{releaseNotes.version}
|
|
|
|
</span>
|
|
|
|
{contentNode}
|
|
|
|
</>
|
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
};
|