diff --git a/src/EmailSummary.tsx b/src/EmailSummary.tsx index 334231d..66d3517 100644 --- a/src/EmailSummary.tsx +++ b/src/EmailSummary.tsx @@ -4,11 +4,9 @@ import ButtonGroup from "react-bootstrap/ButtonGroup"; import ButtonToolbar from "react-bootstrap/ButtonToolbar"; import Placeholder from "react-bootstrap/Placeholder"; import React from "react"; -import Stack from "react-bootstrap/Stack"; import Client from "./client/Client"; import DateTime from "./components/DateTime"; -import EmailFrom from "./components/EmailFrom"; import { IAccount, IEmailStub, IMailbox } from "./client/types"; type EmailSummaryProps = { @@ -51,18 +49,17 @@ class EmailSummary extends React.Component< return ; } return ( - - - -
{stub.from == null ? "?" : stub.from[0].name}
+
-
{stub.subject}
+ + + {" - " + + (stub.from == null ? "?" : stub.from[0].name) + + " - " + + stub.subject} +
- + - +
); } } diff --git a/src/client/Client.tsx b/src/client/Client.tsx index e67bd71..25eb9ab 100644 --- a/src/client/Client.tsx +++ b/src/client/Client.tsx @@ -241,7 +241,7 @@ export default class Client { ); } this.state.session.emailStubs[e.id] = { - from: e.from === null ? [] : e.from, + from: e.from, id: e.id, mailboxIds: e.mailboxIds, receivedAt: e.receivedAt, @@ -370,11 +370,8 @@ export default class Client { .replace("{types}", "*") .replace("{closeafter}", "no") .replace("{ping}", "60"); - this.jclient.subscribeToEvents( - eventSourceUrl, - (type: string, message: PushMessage) => { - console.log("Got an event!", type, message); - }, - ); + this.jclient.subscribeToEvents(eventSourceUrl, (e) => { + console.log("Got an event!", e); + }); } } diff --git a/src/client/jmap-client-ts b/src/client/jmap-client-ts index 5cf6129..2ef5f5b 160000 --- a/src/client/jmap-client-ts +++ b/src/client/jmap-client-ts @@ -1 +1 @@ -Subproject commit 5cf6129a517224b90f79cb96f212d57c5bceb51f +Subproject commit 2ef5f5b7fa0a22a499bd32831ac24622f17e10e6 diff --git a/src/client/types.tsx b/src/client/types.tsx index a251cd0..e8fa48c 100644 --- a/src/client/types.tsx +++ b/src/client/types.tsx @@ -2,7 +2,7 @@ import * as client from "./jmap-client-ts/src/types"; export type MailboxIdMap = { [mailboxId: string]: boolean }; export interface IEmailStub { - from: Array; + from: Array | null; id: string; mailboxIds: MailboxIdMap; receivedAt: string; diff --git a/src/components/DateTime.tsx b/src/components/DateTime.tsx index 91222cd..38c2148 100644 --- a/src/components/DateTime.tsx +++ b/src/components/DateTime.tsx @@ -4,30 +4,16 @@ type DateTimeProps = { d: string; }; -const DateTime: React.FC< - DateTimeProps & React.HTMLAttributes -> = (props) => { - const datetime = Date.parse(props.d); +const DateTime: React.FC = ({ d }) => { + const datetime = Date.parse(d); const now = Date.now(); const diff = (now - datetime) / 1000; - if (diff < 30) return moments ago; - if (diff < 60) return {diff}s; - if (diff < 60 * 60) - return {Math.round(diff / 60)}m; - if (diff < 60 * 60 * 48) - return ( - {Math.round(diff / (60 * 60))}h - ); + if (diff < 30) return moments ago; + if (diff < 60) return {diff}s; + if (diff < 60 * 60) return {Math.round(diff / 60)}m; + if (diff < 60 * 60 * 48) return {Math.round(diff / (60 * 60))}h; if (diff < 60 * 60 * 24 * 365) - return ( - - {Math.round(diff / (60 * 60 * 24))}d - - ); - return ( - - {Math.round(diff / (60 * 60 * 24 * 365))}y - - ); + return {Math.round(diff / (60 * 60 * 24))}d; + return {Math.round(diff / (60 * 60 * 24 * 365))}y; }; export default DateTime; diff --git a/src/components/EmailFrom.tsx b/src/components/EmailFrom.tsx deleted file mode 100644 index aa174a2..0000000 --- a/src/components/EmailFrom.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import React from "react"; -import * as client from "../client/jmap-client-ts/src/types"; - -type EmailFromProps = { - froms: Array; -}; - -const EmailFrom: React.FC = ({ froms }) => { - if (froms.length === 0) { - return None; - } - if (froms.length > 1) { - return MANY?; - } - if (froms[0].name) { - return {froms[0].name}; - } - return {froms[0].email}; -}; -export default EmailFrom; diff --git a/src/style.scss b/src/style.scss index e8cabd0..5de3350 100644 --- a/src/style.scss +++ b/src/style.scss @@ -1,13 +1 @@ @import '~bootstrap/scss/bootstrap'; - -.email-summary { - .email-from { - overflow: hidden; - text-overflow: ellipsis; - width: 200px; - } - .received { - width: 50px; - } -} -