Split email cache into full content and stubs.

This also introduces status for in-flight requests to avoid perpetual,
unnecessary loops of change-the-re-get-data.
This commit is contained in:
Eli Ribble 2024-08-28 19:25:20 -07:00
parent fb53a7506f
commit 4e1922c5fa
8 changed files with 219 additions and 47 deletions

View file

@ -2,13 +2,13 @@ import React from "react";
import Placeholder from "react-bootstrap/Placeholder";
import Client from "./client/Client";
import { IAccount, IEmail, IMailbox } from "./client/types";
import { IAccount, IEmailStub, IMailbox } from "./client/types";
type EmailSummaryProps = {
account: IAccount | null;
client: Client | null;
email: IEmail | null;
emailId: string;
emailStub: IEmailStub | null;
mailbox: IMailbox | null;
};
type EmailSummaryState = {};
@ -27,7 +27,10 @@ class EmailSummary extends React.Component<
ensureData() {
if (this.props.account == null) return;
if (this.props.client == null) return;
this.props.client.ensureEmailGet(this.props.account.id, this.props.emailId);
this.props.client.ensureEmailStub(
this.props.account.id,
this.props.emailId,
);
}
render() {
@ -48,8 +51,8 @@ class EmailSummary extends React.Component<
return (
<div className="p-2 border" key={this.props.emailId}>
<a className="btn" href={href}>
{this.props.email != null
? this.props.email.subject
{this.props.emailStub != null
? this.props.emailStub.subject
: this.props.emailId}
</a>
</div>