import React from 'react'; import moment from 'moment'; import { Dialogs } from '../types/Dialogs'; import { Intl } from './Intl'; import { LocalizerType } from '../types/Util'; export interface PropsType { ackRender: () => void; dialogType: Dialogs; dismissDialog: () => void; hasNetworkDialog: boolean; i18n: LocalizerType; startUpdate: () => void; } type MaybeMoment = moment.Moment | null; type ReactSnoozeHook = React.Dispatch>; const SNOOZE_TIMER = 60 * 1000 * 30; function handleSnooze(setSnoozeForLater: ReactSnoozeHook) { setSnoozeForLater(moment().add(SNOOZE_TIMER)); setTimeout(() => { setSnoozeForLater(moment()); }, SNOOZE_TIMER); } function canSnooze(snoozeUntil: MaybeMoment) { return snoozeUntil === null; } function isSnoozed(snoozeUntil: MaybeMoment) { if (snoozeUntil === null) { return false; } return moment().isBefore(snoozeUntil); } export const UpdateDialog = ({ ackRender, dialogType, dismissDialog, hasNetworkDialog, i18n, startUpdate, }: PropsType): JSX.Element | null => { const [snoozeUntil, setSnoozeForLater] = React.useState(null); React.useEffect(() => { ackRender(); }); if (hasNetworkDialog) { return null; } if (dialogType === Dialogs.None || isSnoozed(snoozeUntil)) { return null; } if (dialogType === Dialogs.Cannot_Update) { return (

{i18n('cannotUpdate')}

https://signal.org/download/ , ]} i18n={i18n} id="cannotUpdateDetail" />
); } if (dialogType === Dialogs.MacOS_Read_Only) { return (

{i18n('cannotUpdate')}

Signal.app, /Applications, ]} i18n={i18n} id="readOnlyVolume" />
); } return (

{i18n('autoUpdateNewVersionTitle')}

{i18n('autoUpdateNewVersionMessage')}
{canSnooze(snoozeUntil) && ( )}
); };