2017-09-27 02:33:08 +08:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-09-27 02:46:00 +08:00
|
|
|
import { RetinaImg } from 'mailspring-component-kit';
|
2017-09-26 06:44:20 +08:00
|
|
|
import moment from 'moment';
|
2017-09-07 07:19:48 +08:00
|
|
|
|
2017-09-27 02:42:18 +08:00
|
|
|
import { FocusedPerspectiveStore } from 'mailspring-exports';
|
2017-09-27 02:33:08 +08:00
|
|
|
import { updateReminderMetadata } from './send-reminders-utils';
|
|
|
|
import { PLUGIN_ID } from './send-reminders-constants';
|
2017-09-07 07:19:48 +08:00
|
|
|
|
|
|
|
class SendRemindersThreadTimestamp extends Component {
|
|
|
|
static displayName = 'SendRemindersThreadTimestamp';
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
thread: PropTypes.object,
|
|
|
|
fallback: PropTypes.func,
|
|
|
|
};
|
|
|
|
|
|
|
|
static containerRequired = false;
|
|
|
|
|
2017-09-26 06:44:20 +08:00
|
|
|
onRemoveReminder(thread) {
|
2017-09-26 14:50:34 +08:00
|
|
|
updateReminderMetadata(thread, {});
|
2017-09-07 07:19:48 +08:00
|
|
|
}
|
|
|
|
|
2017-09-26 06:44:20 +08:00
|
|
|
render() {
|
|
|
|
const Fallback = this.props.fallback;
|
2017-09-27 02:33:08 +08:00
|
|
|
const current = FocusedPerspectiveStore.current();
|
2017-09-07 07:19:48 +08:00
|
|
|
|
2017-09-26 06:44:20 +08:00
|
|
|
if (!current.isReminders) {
|
2017-09-27 02:33:08 +08:00
|
|
|
return <Fallback {...this.props} />;
|
2017-09-07 07:19:48 +08:00
|
|
|
}
|
|
|
|
|
2017-09-27 02:33:08 +08:00
|
|
|
const { expiration } = this.props.thread.metadataForPluginId(PLUGIN_ID);
|
2017-09-26 06:44:20 +08:00
|
|
|
if (!expiration) {
|
2017-09-27 02:33:08 +08:00
|
|
|
return <Fallback {...this.props} />;
|
2017-09-07 07:19:48 +08:00
|
|
|
}
|
2017-09-26 06:44:20 +08:00
|
|
|
|
|
|
|
const mExpiration = moment(expiration);
|
|
|
|
|
2017-09-07 07:19:48 +08:00
|
|
|
return (
|
2017-09-26 06:44:20 +08:00
|
|
|
<span
|
|
|
|
className="send-reminders-thread-timestamp timestamp"
|
|
|
|
title={`Reminder set for ${mExpiration.fromNow(true)} from now`}
|
|
|
|
>
|
2017-09-27 02:33:08 +08:00
|
|
|
<RetinaImg name="ic-timestamp-reminder.png" mode={RetinaImg.Mode.ContentIsMask} />
|
|
|
|
<span className="date-message">{`in ${mExpiration.fromNow(true)}`}</span>
|
2017-09-07 07:19:48 +08:00
|
|
|
</span>
|
2017-09-27 02:33:08 +08:00
|
|
|
);
|
2017-09-07 07:19:48 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-27 02:33:08 +08:00
|
|
|
export default SendRemindersThreadTimestamp;
|