2021-07-22 07:04:46 +02:00
|
|
|
import React from 'react';
|
2018-07-09 23:29:13 +02:00
|
|
|
|
|
|
|
import { Intl } from '../Intl';
|
|
|
|
|
|
|
|
import { missingCaseError } from '../../util/missingCaseError';
|
2021-08-30 09:57:31 +02:00
|
|
|
import { SessionIcon } from '../session/icon';
|
2021-07-05 07:54:35 +02:00
|
|
|
import { PropsForExpirationTimer } from '../../state/ducks/conversations';
|
2021-07-30 08:26:58 +02:00
|
|
|
import { ReadableMessage } from './ReadableMessage';
|
2018-07-09 23:29:13 +02:00
|
|
|
|
2021-07-22 07:04:46 +02:00
|
|
|
const TimerNotificationContent = (props: PropsForExpirationTimer) => {
|
|
|
|
const { phoneNumber, profileName, timespan, type, disabled } = props;
|
|
|
|
const changeKey = disabled ? 'disabledDisappearingMessages' : 'theyChangedTheTimer';
|
2018-07-09 23:29:13 +02:00
|
|
|
|
2021-07-22 07:04:46 +02:00
|
|
|
const contact = (
|
|
|
|
<span key={`external-${phoneNumber}`} className="module-timer-notification__contact">
|
|
|
|
{profileName || phoneNumber}
|
|
|
|
</span>
|
|
|
|
);
|
2020-04-06 08:32:50 +02:00
|
|
|
|
2021-07-22 07:04:46 +02:00
|
|
|
switch (type) {
|
|
|
|
case 'fromOther':
|
|
|
|
return <Intl id={changeKey} components={[contact, timespan]} />;
|
|
|
|
case 'fromMe':
|
|
|
|
return disabled
|
|
|
|
? window.i18n('youDisabledDisappearingMessages')
|
|
|
|
: window.i18n('youChangedTheTimer', [timespan]);
|
|
|
|
case 'fromSync':
|
|
|
|
return disabled
|
|
|
|
? window.i18n('disappearingMessagesDisabled')
|
|
|
|
: window.i18n('timerSetOnSync', [timespan]);
|
|
|
|
default:
|
|
|
|
throw missingCaseError(type);
|
2018-07-09 23:29:13 +02:00
|
|
|
}
|
2021-07-22 07:04:46 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
export const TimerNotification = (props: PropsForExpirationTimer) => {
|
2021-07-30 08:26:58 +02:00
|
|
|
const { messageId, receivedAt, isUnread } = props;
|
|
|
|
|
2020-11-04 03:43:34 +01:00
|
|
|
return (
|
2021-07-30 08:26:58 +02:00
|
|
|
<ReadableMessage
|
|
|
|
messageId={messageId}
|
|
|
|
receivedAt={receivedAt}
|
|
|
|
isUnread={isUnread}
|
|
|
|
key={`readable-message-${messageId}`}
|
|
|
|
>
|
|
|
|
<div className="module-timer-notification" id={`msg-${props.messageId}`}>
|
|
|
|
<div className="module-timer-notification__message">
|
|
|
|
<div>
|
2021-08-30 09:57:31 +02:00
|
|
|
<SessionIcon iconType="stopwatch" iconSize={'small'} iconColor={'#ABABAB'} />
|
2021-07-30 08:26:58 +02:00
|
|
|
</div>
|
2020-11-04 03:43:34 +01:00
|
|
|
|
2021-07-30 08:26:58 +02:00
|
|
|
<div>
|
|
|
|
<TimerNotificationContent {...props} />
|
|
|
|
</div>
|
2021-07-22 07:04:46 +02:00
|
|
|
</div>
|
2018-07-09 23:29:13 +02:00
|
|
|
</div>
|
2021-07-30 08:26:58 +02:00
|
|
|
</ReadableMessage>
|
2020-11-04 03:43:34 +01:00
|
|
|
);
|
|
|
|
};
|