2024-08-28 09:21:31 -07:00
|
|
|
import React from "react";
|
2024-08-28 10:16:11 -07:00
|
|
|
import Placeholder from "react-bootstrap/Placeholder";
|
|
|
|
|
2024-08-28 09:21:31 -07:00
|
|
|
import Client from "./client/Client";
|
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 = {
|
|
|
|
account: IAccount | null;
|
|
|
|
client: Client | null;
|
|
|
|
emailId: string;
|
2024-08-28 19:25:20 -07:00
|
|
|
emailStub: IEmailStub | null;
|
2024-08-28 10:16:11 -07:00
|
|
|
mailbox: IMailbox | null;
|
2024-08-28 09:21:31 -07:00
|
|
|
};
|
|
|
|
type EmailSummaryState = {};
|
|
|
|
|
|
|
|
class EmailSummary extends React.Component<
|
|
|
|
EmailSummaryProps,
|
|
|
|
EmailSummaryState
|
|
|
|
> {
|
|
|
|
componentDidMount() {
|
|
|
|
this.ensureData();
|
|
|
|
}
|
|
|
|
componentDidUpdate() {
|
|
|
|
this.ensureData();
|
|
|
|
}
|
|
|
|
|
|
|
|
ensureData() {
|
|
|
|
if (this.props.account == null) return;
|
|
|
|
if (this.props.client == null) return;
|
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
|
|
|
if (this.props.account == null || this.props.mailbox == null) {
|
|
|
|
return (
|
|
|
|
<div className="p-2 border pe-auto" key={this.props.emailId}>
|
|
|
|
<Placeholder animation="glow" />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
const href =
|
|
|
|
"#" +
|
|
|
|
this.props.account.id +
|
|
|
|
"/" +
|
|
|
|
this.props.mailbox.id +
|
|
|
|
"/" +
|
|
|
|
this.props.emailId;
|
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-28 19:25:20 -07:00
|
|
|
{this.props.emailStub != null
|
|
|
|
? this.props.emailStub.subject
|
2024-08-28 10:16:11 -07:00
|
|
|
: this.props.emailId}
|
|
|
|
</a>
|
2024-08-28 09:21:31 -07:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
export default EmailSummary;
|