import React from 'react';
import {
ListTabular,
RetinaImg,
MailLabelSet,
MailImportantIcon,
InjectedComponent,
InjectedComponentSet,
} from 'mailspring-component-kit';
import { localized, FocusedPerspectiveStore, Utils, DateUtils } from 'mailspring-exports';
import { ThreadArchiveQuickAction, ThreadTrashQuickAction } from './thread-list-quick-actions';
import ThreadListParticipants from './thread-list-participants';
import ThreadListIcon from './thread-list-icon';
// Get and format either last sent or last received timestamp depending on thread-list being viewed
const ThreadListTimestamp = function({ thread }) {
const rawTimestamp = FocusedPerspectiveStore.current().isSent()
? thread.lastMessageSentTimestamp
: thread.lastMessageReceivedTimestamp;
const timestamp = rawTimestamp ? DateUtils.shortTimeString(rawTimestamp) : localized('No Date');
return {timestamp};
};
ThreadListTimestamp.containerRequired = false;
const subject = function(subj) {
if ((subj || '').trim().length === 0) {
return {localized('(No Subject)')};
} else if (subj.split(/([\uD800-\uDBFF][\uDC00-\uDFFF])/g).length > 1) {
const subjComponents = [];
const subjParts = subj.split(/([\uD800-\uDBFF][\uDC00-\uDFFF])/g);
for (let idx = 0; idx < subjParts.length; idx++) {
const part = subjParts[idx];
if (part.match(/([\uD800-\uDBFF][\uDC00-\uDFFF])/g)) {
subjComponents.push(
{part}
);
} else {
subjComponents.push({part});
}
}
return subjComponents;
} else {
return subj;
}
};
const getSnippet = function(thread) {
const messages = thread.__messages || [];
if (messages.length === 0) {
return thread.snippet;
}
for (let ii = messages.length - 1; ii >= 0; ii--) {
if (messages[ii].snippet) return messages[ii].snippet;
}
return null;
};
const c1 = new ListTabular.Column({
name: '★',
resolver: thread => {
return [