mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-04 03:34:28 +08:00
feat(sidebar): add timestamps to related messages
This commit is contained in:
parent
8475afbbfb
commit
89323b05db
5 changed files with 30 additions and 15 deletions
|
@ -19,11 +19,12 @@ class MessageTimestamp extends React.Component
|
|||
nowDate = @_today()
|
||||
formattedDate = @_formattedDate(msgDate, nowDate, @props.isDetailed)
|
||||
<div className={@props.className}
|
||||
title={Utils.fullTimeString(@props.date)}
|
||||
onClick={@props.onClick}>{formattedDate}</div>
|
||||
|
||||
_formattedDate: (msgDate, now, isDetailed) =>
|
||||
if isDetailed
|
||||
return msgDate.format "MMMM D, YYYY [at] h:mm A"
|
||||
return msgDate.format "MMMM D, YYYY [at] h:mm A z"
|
||||
else
|
||||
diff = now.diff(msgDate, 'days', true)
|
||||
isSameDay = now.isSame(msgDate, 'days')
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import React from 'react'
|
||||
import {Actions} from 'nylas-exports'
|
||||
import {Utils, Actions} from 'nylas-exports'
|
||||
|
||||
export default class RelatedThreads extends React.Component {
|
||||
static displayName = "RelatedThreads";
|
||||
|
@ -53,7 +53,8 @@ export default class RelatedThreads extends React.Component {
|
|||
const onClick = () => { this._onClick(thread) }
|
||||
return (
|
||||
<div key={thread.id} className="related-thread" onClick={onClick} >
|
||||
{thread.subject}
|
||||
<span className="subject" title={thread.subject}>{thread.subject}</span>
|
||||
<span className="timestamp" title={Utils.fullTimeString(thread.lastMessageReceivedTimestamp)}>{Utils.shortTimeString(thread.lastMessageReceivedTimestamp)}</span>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
|
|
|
@ -13,14 +13,20 @@
|
|||
border-radius: 0 0 @border-radius-large @border-radius-large;
|
||||
|
||||
.related-thread {
|
||||
display: flex;
|
||||
font-size: 12px;
|
||||
color: #566f86;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
padding: 0.5em 15px;
|
||||
border-top: 1px solid rgba(0,0,0,0.08);
|
||||
|
||||
.subject {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
padding-right: 1em;
|
||||
}
|
||||
}
|
||||
|
||||
.toggle {
|
||||
|
|
|
@ -1,16 +1,9 @@
|
|||
moment = require "moment"
|
||||
{Utils} = require 'nylas-exports'
|
||||
React = require 'react'
|
||||
|
||||
module.exports =
|
||||
timestamp: (time) ->
|
||||
diff = moment().diff(time, 'days', true)
|
||||
if diff <= 1
|
||||
format = "h:mm a"
|
||||
else if diff > 1 and diff <= 365
|
||||
format = "MMM D"
|
||||
else
|
||||
format = "MMM D YYYY"
|
||||
moment(time).format(format)
|
||||
Utils.shortTimeString(time)
|
||||
|
||||
subject: (subj) ->
|
||||
if (subj ? "").trim().length is 0
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
_ = require 'underscore'
|
||||
fs = require('fs-plus')
|
||||
path = require('path')
|
||||
moment = require('moment-timezone')
|
||||
tz = Intl.DateTimeFormat().resolvedOptions().timeZone
|
||||
|
||||
TaskRegistry = null
|
||||
|
@ -37,6 +38,19 @@ Utils =
|
|||
|
||||
timeZone: tz
|
||||
|
||||
shortTimeString: (time) ->
|
||||
diff = moment().diff(time, 'days', true)
|
||||
if diff <= 1
|
||||
format = "h:mm a"
|
||||
else if diff > 1 and diff <= 365
|
||||
format = "MMM D"
|
||||
else
|
||||
format = "MMM D YYYY"
|
||||
moment(time).format(format)
|
||||
|
||||
fullTimeString: (time) ->
|
||||
moment(time).tz(Utils.timeZone).format("dddd, MMMM Do YYYY, h:mm:ss a z")
|
||||
|
||||
isHash: (object) ->
|
||||
_.isObject(object) and not _.isFunction(object) and not _.isArray(object)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue