2024-08-28 10:16:11 -07:00
|
|
|
import Placeholder from "react-bootstrap/Placeholder";
|
2024-08-30 07:40:40 -07:00
|
|
|
import React from "react";
|
2024-08-28 10:16:11 -07:00
|
|
|
|
2024-08-28 09:21:31 -07:00
|
|
|
import Client from "./client/Client";
|
2024-08-30 07:40:40 -07:00
|
|
|
import DateTime from "./components/DateTime";
|
2024-08-28 19:25:20 -07:00
|
|
|
import { IAccount, IEmailStub, IMailbox } from "./client/types";
|
2024-08-28 09:21:31 -07:00
|
|
|
|
|
|
|
type EmailSummaryProps = {
|
2024-08-30 07:40:40 -07:00
|
|
|
account: IAccount;
|
|
|
|
client: Client;
|
2024-08-28 09:21:31 -07:00
|
|
|
emailId: string;
|
2024-08-28 19:25:20 -07:00
|
|
|
emailStub: IEmailStub | null;
|
2024-08-30 07:40:40 -07:00
|
|
|
mailbox: IMailbox;
|
2024-08-28 09:21:31 -07:00
|
|
|
};
|
|
|
|
type EmailSummaryState = {};
|
|
|
|
|
|
|
|
class EmailSummary extends React.Component<
|
|
|
|
EmailSummaryProps,
|
|
|
|
EmailSummaryState
|
|
|
|
> {
|
|
|
|
componentDidMount() {
|
|
|
|
this.ensureData();
|
|
|
|
}
|
|
|
|
componentDidUpdate() {
|
|
|
|
this.ensureData();
|
|
|
|
}
|
|
|
|
|
|
|
|
ensureData() {
|
2024-08-28 19:25:20 -07:00
|
|
|
this.props.client.ensureEmailStub(
|
|
|
|
this.props.account.id,
|
|
|
|
this.props.emailId,
|
|
|
|
);
|
2024-08-28 09:21:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2024-08-28 10:16:11 -07:00
|
|
|
const href =
|
|
|
|
"#" +
|
|
|
|
this.props.account.id +
|
|
|
|
"/" +
|
|
|
|
this.props.mailbox.id +
|
|
|
|
"/" +
|
|
|
|
this.props.emailId;
|
2024-08-29 10:47:09 -07:00
|
|
|
const stub = this.props.emailStub;
|
2024-08-30 07:40:40 -07:00
|
|
|
if (stub === null) {
|
|
|
|
return <Placeholder />;
|
|
|
|
}
|
2024-08-28 09:21:31 -07:00
|
|
|
return (
|
2024-08-28 09:38:50 -07:00
|
|
|
<div className="p-2 border" key={this.props.emailId}>
|
2024-08-28 10:16:11 -07:00
|
|
|
<a className="btn" href={href}>
|
2024-08-30 07:40:40 -07:00
|
|
|
<DateTime d={stub.receivedAt} />
|
|
|
|
<span>
|
|
|
|
{" - " +
|
2024-08-29 10:47:09 -07:00
|
|
|
(stub.from == null ? "?" : stub.from[0].name) +
|
|
|
|
" - " +
|
2024-08-30 07:40:40 -07:00
|
|
|
stub.subject}
|
|
|
|
</span>
|
2024-08-28 10:16:11 -07:00
|
|
|
</a>
|
2024-08-28 09:21:31 -07:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
export default EmailSummary;
|