2024-08-27 23:22:11 -07:00
|
|
|
import React from "react";
|
|
|
|
import Stack from "react-bootstrap/Stack";
|
|
|
|
|
|
|
|
import Client from "./client/Client";
|
|
|
|
import { IAccount, IMailbox } from "./client/types";
|
2024-08-28 09:21:31 -07:00
|
|
|
import EmailSummary from "./EmailSummary";
|
2024-08-27 23:22:11 -07:00
|
|
|
|
|
|
|
type EmailListProps = {
|
|
|
|
account: IAccount | null;
|
|
|
|
client: Client | null;
|
|
|
|
mailbox: IMailbox | null;
|
|
|
|
};
|
|
|
|
|
|
|
|
type EmailListState = {};
|
|
|
|
|
|
|
|
class EmailList extends React.Component<EmailListProps, EmailListState> {
|
|
|
|
componentDidUpdate() {
|
|
|
|
if (this.props.account == null) return;
|
|
|
|
if (this.props.client == null) return;
|
|
|
|
if (this.props.mailbox == null) return;
|
2024-08-28 09:21:31 -07:00
|
|
|
this.props.client.ensureEmailList(
|
2024-08-27 23:22:11 -07:00
|
|
|
this.props.account.id,
|
|
|
|
this.props.mailbox.id,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2024-08-28 00:58:32 -07:00
|
|
|
if (
|
|
|
|
this.props.account == null ||
|
2024-08-28 09:21:31 -07:00
|
|
|
this.props.client == null ||
|
2024-08-28 00:58:32 -07:00
|
|
|
this.props.mailbox == null ||
|
|
|
|
this.props.mailbox.emailIds == null
|
|
|
|
) {
|
|
|
|
return <Stack />;
|
|
|
|
} else {
|
|
|
|
return (
|
|
|
|
<Stack>
|
2024-08-28 09:21:31 -07:00
|
|
|
{this.props.mailbox.emailIds.slice(0, 5).map((e) => (
|
|
|
|
<EmailSummary
|
|
|
|
account={this.props.account}
|
|
|
|
client={this.props.client}
|
|
|
|
emailId={e}
|
|
|
|
email={this.props.client!.email(e)}
|
|
|
|
key={e}
|
|
|
|
/>
|
2024-08-28 00:58:32 -07:00
|
|
|
))}
|
|
|
|
</Stack>
|
|
|
|
);
|
|
|
|
}
|
2024-08-27 23:22:11 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
export default EmailList;
|