Show email subject lines.
This includes a bunch of new things. I've introduced "ensureEmail..." to indicate that the UI would like some data to be populated, but if it is already present we don't need to do anything. I've also introduced a cache for emails that is keyed on the email ID. I don't know if email IDs are unique. They look like they should be globally unique within a given server, but I'm not sure and the standard is unclear. It'll need some experimentation.
This commit is contained in:
parent
5c7e67a2bd
commit
a34d8f53b3
4 changed files with 107 additions and 23 deletions
40
src/EmailSummary.tsx
Normal file
40
src/EmailSummary.tsx
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import React from "react";
|
||||
import Client from "./client/Client";
|
||||
import { IAccount, IEmail } from "./client/types";
|
||||
|
||||
type EmailSummaryProps = {
|
||||
account: IAccount | null;
|
||||
client: Client | null;
|
||||
email: IEmail | null;
|
||||
emailId: string;
|
||||
};
|
||||
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;
|
||||
this.props.client.ensureEmailGet(this.props.account.id, this.props.emailId);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="p-2" key={this.props.emailId}>
|
||||
{this.props.email != null
|
||||
? this.props.email.subject
|
||||
: this.props.emailId}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
export default EmailSummary;
|
||||
Loading…
Add table
Add a link
Reference in a new issue