// Copyright 2018-2020 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import React from 'react'; import classNames from 'classnames'; import { ContactName } from './ContactName'; import { Intl } from '../Intl'; import { LocalizerType } from '../../types/Util'; export type TimerNotificationType = | 'fromOther' | 'fromMe' | 'fromSync' | 'fromMember'; export type PropsData = { type: TimerNotificationType; phoneNumber?: string; profileName?: string; title: string; name?: string; disabled: boolean; timespan: string; }; type PropsHousekeeping = { i18n: LocalizerType; }; export type Props = PropsData & PropsHousekeeping; export class TimerNotification extends React.Component { public renderContents(): JSX.Element | string | null { const { i18n, name, phoneNumber, profileName, title, timespan, type, disabled, } = this.props; const changeKey = disabled ? 'disabledDisappearingMessages' : 'theyChangedTheTimer'; switch (type) { case 'fromOther': return ( ), time: timespan, }} /> ); case 'fromMe': return disabled ? i18n('youDisabledDisappearingMessages') : i18n('youChangedTheTimer', [timespan]); case 'fromSync': return disabled ? i18n('disappearingMessagesDisabled') : i18n('timerSetOnSync', [timespan]); case 'fromMember': return disabled ? i18n('disappearingMessagesDisabledByMember') : i18n('timerSetByMember', [timespan]); default: window.log.warn('TimerNotification: unsupported type provided:', type); return null; } } public render(): JSX.Element { const { timespan, disabled } = this.props; return (
{timespan}
{this.renderContents()}
); } }