From d71f18cce1041a4fc121f8a27b19999cf1d683b0 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Thu, 29 Aug 2024 10:27:00 -0700 Subject: [PATCH] Show text content, and if unavailable, the HTML content. This required actually requesting all the body values, and mapping from the body values to to body parts for display. --- src/EmailContent.tsx | 41 ++++++++++++++++++++++++++++++++++++++--- src/client/Client.tsx | 1 + 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/EmailContent.tsx b/src/EmailContent.tsx index 6506fdf..9dc3f3b 100644 --- a/src/EmailContent.tsx +++ b/src/EmailContent.tsx @@ -1,5 +1,6 @@ -import React from "react"; import Placeholder from "react-bootstrap/Placeholder"; +import React from "react"; +import Stack from "react-bootstrap/Stack"; import Client from "./client/Client"; import { IAccount, IEmail } from "./client/types"; @@ -34,10 +35,44 @@ class EmailContent extends React.Component< } render() { - if (this.props.email == null) { + const email = this.props.email; + if (email == null || email.bodyValues == null) { return ; + } else if (email.textBody != null) { + return ( + +
  • {email.receivedAt}
  • + {email.textBody.map((t) => + t.partId === undefined ? ( + + ) : ( +
    + ), + )} + + ); + } else if (email.htmlBody != null) { + return ( + + {email.htmlBody.map((h) => + h.partId === undefined ? ( + + ) : ( +
    + ), + )} + + ); } else { - return

    {this.props.email.preview}

    ; + return

    Nothing to display :/

    ; } } } diff --git a/src/client/Client.tsx b/src/client/Client.tsx index 368ba74..cc22889 100644 --- a/src/client/Client.tsx +++ b/src/client/Client.tsx @@ -112,6 +112,7 @@ export default class Client { .email_get({ accountId: accountId, ids: [emailId], + fetchAllBodyValues: true, }) .then((response) => { console.log(msg, "response", response);