import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { RetinaImg } from 'mailspring-component-kit'; import moment from 'moment'; import { localized, FocusedPerspectiveStore } from 'mailspring-exports'; import { updateReminderMetadata } from './send-reminders-utils'; import { PLUGIN_ID } from './send-reminders-constants'; class SendRemindersThreadTimestamp extends Component { static displayName = 'SendRemindersThreadTimestamp'; static propTypes = { thread: PropTypes.object, fallback: PropTypes.func, }; static containerRequired = false; onRemoveReminder(thread) { updateReminderMetadata(thread, {}); } render() { const Fallback = this.props.fallback; const current = FocusedPerspectiveStore.current(); if (!current.isReminders) { return ; } const { expiration } = this.props.thread.metadataForPluginId(PLUGIN_ID); if (!expiration) { return ; } const mExpiration = moment(expiration); return ( {localized('in %@', mExpiration.fromNow(true))} ); } } export default SendRemindersThreadTimestamp;