UNPKG

stream-chat-react

Version:

React components to create chat conversations or livestream style chat

31 lines (30 loc) 1.53 kB
import React from 'react'; import { useTranslationContext } from '../../context'; import { useStateStore } from '../../store'; const reminderStateSelector = (state) => ({ timeLeftMs: state.timeLeftMs, }); export const ReminderNotification = ({ reminder }) => { const { t } = useTranslationContext(); const { timeLeftMs } = useStateStore(reminder?.state, reminderStateSelector) ?? {}; const stopRefreshBoundaryMs = reminder?.timer.stopRefreshBoundaryMs; const stopRefreshTimeStamp = reminder?.remindAt && stopRefreshBoundaryMs ? reminder?.remindAt.getTime() + stopRefreshBoundaryMs : undefined; const isBehindRefreshBoundary = !!stopRefreshTimeStamp && new Date().getTime() > stopRefreshTimeStamp; return (React.createElement("p", { className: 'str-chat__message-reminder' }, React.createElement("span", null, t('Saved for later')), reminder?.remindAt && timeLeftMs !== null && (React.createElement(React.Fragment, null, React.createElement("span", null, " | "), React.createElement("span", null, isBehindRefreshBoundary ? t('Due since {{ dueSince }}', { dueSince: t(`timestamp/ReminderNotification`, { timestamp: reminder.remindAt, }), }) : t(`Due {{ timeLeft }}`, { timeLeft: t('duration/Message reminder', { milliseconds: timeLeftMs, }), })))))); };