2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2021 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-04-07 19:48:02 +00:00
|
|
|
features: [
|
2022-04-15 22:18:47 +00:00
|
|
|
{
|
2023-01-12 20:38:32 +00:00
|
|
|
key: 'icu:WhatsNew__v6.3--0',
|
|
|
|
components: {
|
|
|
|
whynothugo: <a href="https://github.com/WhyNotHugo">@WhyNotHugo</a>,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'icu:WhatsNew__v6.3--1',
|
|
|
|
components: {
|
|
|
|
jojomatik: <a href="https://github.com/jojomatik">@jojomatik</a>,
|
|
|
|
},
|
2022-10-07 18:34:27 +00:00
|
|
|
},
|
2022-04-07 19:48:02 +00:00
|
|
|
],
|
2021-10-23 00:41:45 +00:00
|
|
|
};
|
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function WhatsNewModal({
|
2021-10-23 00:41:45 +00:00
|
|
|
i18n,
|
|
|
|
hideWhatsNewModal,
|
2022-11-18 00:45:19 +00:00
|
|
|
}: PropsType): JSX.Element {
|
2021-10-23 00:41:45 +00:00
|
|
|
let contentNode: ReactChild;
|
|
|
|
|
|
|
|
if (releaseNotes.features.length === 1) {
|
|
|
|
const { key, components } = releaseNotes.features[0];
|
|
|
|
contentNode = (
|
|
|
|
<p>
|
2023-01-05 22:43:33 +00:00
|
|
|
{/* eslint-disable-next-line local-rules/valid-i18n-keys */}
|
2021-10-23 00:41:45 +00:00
|
|
|
<Intl
|
|
|
|
i18n={i18n}
|
|
|
|
id={key}
|
|
|
|
renderText={renderText}
|
|
|
|
components={components}
|
|
|
|
/>
|
|
|
|
</p>
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
contentNode = (
|
|
|
|
<ul>
|
|
|
|
{releaseNotes.features.map(({ key, components }) => (
|
|
|
|
<li key={key}>
|
2023-01-05 22:43:33 +00:00
|
|
|
{/* eslint-disable-next-line local-rules/valid-i18n-keys */}
|
2021-10-23 00:41:45 +00:00
|
|
|
<Intl
|
|
|
|
i18n={i18n}
|
|
|
|
id={key}
|
|
|
|
renderText={renderText}
|
|
|
|
components={components}
|
|
|
|
/>
|
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
</ul>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Modal
|
2022-09-27 20:24:21 +00:00
|
|
|
modalName="WhatsNewModal"
|
2021-10-23 00:41:45 +00:00
|
|
|
hasXButton
|
|
|
|
i18n={i18n}
|
|
|
|
onClose={hideWhatsNewModal}
|
|
|
|
title={i18n('WhatsNew__modal-title')}
|
|
|
|
>
|
|
|
|
<>
|
|
|
|
<span>
|
|
|
|
{moment(releaseNotes.date).format('LL')} ·{' '}
|
|
|
|
{releaseNotes.version}
|
|
|
|
</span>
|
|
|
|
{contentNode}
|
|
|
|
</>
|
|
|
|
</Modal>
|
|
|
|
);
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|