_ = require 'underscore' React = require 'react' classNames = require 'classnames' moment = require 'moment' {ListTabular, RetinaImg, MailLabelSet, MailImportantIcon, InjectedComponent, InjectedComponentSet} = require 'nylas-component-kit' {Thread, FocusedPerspectiveStore, Utils, DateUtils} = require 'nylas-exports' {ThreadArchiveQuickAction, ThreadTrashQuickAction} = require './thread-list-quick-actions' ThreadListParticipants = require './thread-list-participants' ThreadListStore = require './thread-list-store' ThreadListIcon = require './thread-list-icon' # Get and format either last sent or last received timestamp depending on thread-list being viewed ThreadListTimestamp = ({thread}) -> if FocusedPerspectiveStore.current().isSent() rawTimestamp = thread.lastMessageSentTimestamp else rawTimestamp = thread.lastMessageReceivedTimestamp timestamp = DateUtils.shortTimeString(rawTimestamp) return {timestamp} ThreadListTimestamp.containerRequired = false subject = (subj) -> if (subj ? "").trim().length is 0 return (No Subject) else if subj.split(/([\uD800-\uDBFF][\uDC00-\uDFFF])/g).length > 1 subjComponents = [] subjParts = subj.split /([\uD800-\uDBFF][\uDC00-\uDFFF])/g for part, idx in subjParts if part.match /([\uD800-\uDBFF][\uDC00-\uDFFF])/g subjComponents.push {part} else subjComponents.push {part} return subjComponents else return subj getSnippet = (thread) -> messages = thread.__messages || [] if (messages.length is 0) return thread.snippet return messages[messages.length - 1].snippet c1 = new ListTabular.Column name: "★" resolver: (thread) => [ ] c2 = new ListTabular.Column name: "Participants" width: 200 resolver: (thread) => hasDraft = (thread.__messages || []).find((m) => m.draft) if hasDraft
else c3 = new ListTabular.Column name: "Message" flex: 4 resolver: (thread) => attachment = false messages = thread.__messages || [] hasAttachments = thread.hasAttachments and messages.find (m) -> Utils.showIconForAttachments(m.files) if hasAttachments attachment =
{subject(thread.subject)} {getSnippet(thread)} {attachment} c4 = new ListTabular.Column name: "Date" resolver: (thread) => return ( ) c5 = new ListTabular.Column name: "HoverActions" resolver: (thread) =>
]} matching={role: "ThreadListQuickAction"} className="thread-injected-quick-actions" exposedProps={thread: thread} />
cNarrow = new ListTabular.Column name: "Item" flex: 1 resolver: (thread) => pencil = false attachment = false messages = thread.__messages || [] hasAttachments = thread.hasAttachments and messages.find (m) -> Utils.showIconForAttachments(m.files) if hasAttachments attachment =
hasDraft = messages.find((m) => m.draft) if hasDraft pencil = # TODO We are limiting the amount on injected icons in narrow mode to 1 # until we revisit the UI to accommodate more icons
{pencil} {attachment}
{subject(thread.subject)}
{getSnippet(thread)} 
module.exports = Narrow: [cNarrow] Wide: [c1, c2, c3, c4, c5]