signal-desktop/ts/components/conversation/UniversalTimerNotification.tsx

34 lines
807 B
TypeScript
Raw Normal View History

2021-06-01 13:45:43 -07:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React from 'react';
import { SystemMessage } from './SystemMessage';
import type { LocalizerType } from '../../types/Util';
2021-06-01 13:45:43 -07:00
import * as expirationTimer from '../../util/expirationTimer';
2022-11-16 12:18:02 -08:00
import type { DurationInSeconds } from '../../util/durations';
2021-06-01 13:45:43 -07:00
export type Props = {
i18n: LocalizerType;
2022-11-16 12:18:02 -08:00
expireTimer: DurationInSeconds;
2021-06-01 13:45:43 -07:00
};
2022-11-17 16:45:19 -08:00
export function UniversalTimerNotification(props: Props): JSX.Element | null {
2021-06-01 13:45:43 -07:00
const { i18n, expireTimer } = props;
if (!expireTimer) {
return null;
}
const timeValue = expirationTimer.format(i18n, expireTimer);
2021-06-01 13:45:43 -07:00
return (
<SystemMessage
icon="timer"
2023-03-29 17:03:25 -07:00
contents={i18n('icu:UniversalTimerNotification__text', {
timeValue,
})}
/>
2021-06-01 13:45:43 -07:00
);
2022-11-17 16:45:19 -08:00
}