import React from 'react'; import classNames from 'classnames'; import { ContactName } from './ContactName'; import { Intl } from '../Intl'; import { LocalizerType } from '../../types/Util'; import { missingCaseError } from '../../util/missingCaseError'; export type PropsData = { type: 'fromOther' | 'fromMe' | 'fromSync'; phoneNumber: string; profileName?: string; name?: string; disabled: boolean; timespan: string; }; type PropsHousekeeping = { i18n: LocalizerType; }; type Props = PropsData & PropsHousekeeping; export class TimerNotification extends React.Component { public renderContents() { const { i18n, name, phoneNumber, profileName, timespan, type, disabled, } = this.props; const changeKey = disabled ? 'disabledDisappearingMessages' : 'theyChangedTheTimer'; switch (type) { case 'fromOther': return ( , timespan, ]} /> ); case 'fromMe': return disabled ? i18n('youDisabledDisappearingMessages') : i18n('youChangedTheTimer', [timespan]); case 'fromSync': return disabled ? i18n('disappearingMessagesDisabled') : i18n('timerSetOnSync', [timespan]); default: throw missingCaseError(type); } } public render() { const { timespan, disabled } = this.props; return (
{timespan}
{this.renderContents()}
); } }