2017-09-07 07:19:48 +08:00
|
|
|
import React, {Component} from 'react';
|
|
|
|
import PropTypes from 'prop-types'
|
|
|
|
import {RetinaImg} from 'nylas-component-kit';
|
2017-09-26 06:44:20 +08:00
|
|
|
import moment from 'moment';
|
2017-09-07 07:19:48 +08:00
|
|
|
|
2017-09-26 06:44:20 +08:00
|
|
|
import {FocusedPerspectiveStore} from 'nylas-exports';
|
|
|
|
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) {
|
|
|
|
updateReminderMetadata(thread, {expiration: null});
|
2017-09-07 07:19:48 +08:00
|
|
|
}
|
|
|
|
|
2017-09-26 06:44:20 +08:00
|
|
|
render() {
|
|
|
|
const Fallback = this.props.fallback;
|
|
|
|
const current = FocusedPerspectiveStore.current()
|
2017-09-07 07:19:48 +08:00
|
|
|
|
2017-09-26 06:44:20 +08:00
|
|
|
if (!current.isReminders) {
|
|
|
|
return <Fallback {...this.props} />
|
2017-09-07 07:19:48 +08:00
|
|
|
}
|
|
|
|
|
2017-09-26 06:44:20 +08:00
|
|
|
const {expiration} = this.props.thread.metadataForPluginId(PLUGIN_ID);
|
|
|
|
if (!expiration) {
|
2017-09-07 07:19:48 +08:00
|
|
|
return <Fallback {...this.props} />
|
|
|
|
}
|
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-07 07:19:48 +08:00
|
|
|
<RetinaImg
|
|
|
|
name="ic-timestamp-reminder.png"
|
|
|
|
mode={RetinaImg.Mode.ContentIsMask}
|
|
|
|
/>
|
|
|
|
<span className="date-message">
|
2017-09-26 06:44:20 +08:00
|
|
|
{`in ${mExpiration.fromNow(true)}`}
|
2017-09-07 07:19:48 +08:00
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SendRemindersThreadTimestamp
|