diff --git a/web/src/components/emails/EmailTableRow.tsx b/web/src/components/emails/EmailTableRow.tsx index 18e6c81ec1..5422c384b6 100644 --- a/web/src/components/emails/EmailTableRow.tsx +++ b/web/src/components/emails/EmailTableRow.tsx @@ -1,3 +1,4 @@ +import { CheckIcon } from '@heroicons/react/20/solid' import { useContext } from 'react' import { useNavigate } from 'react-router-dom' @@ -11,14 +12,12 @@ import { formatDate } from 'utils/time' interface EmailTableRowProps { email: EmailInfo selected: boolean - onClick: (action: 'add' | 'replace') => void + onClick: () => void } export default function EmailTableRow(props: EmailTableRowProps) { - const { email, onClick } = props - const backgroundClassName = props.selected - ? ' bg-blue-100 dark:bg-neutral-700' - : '' + const { email, onClick, selected } = props + const backgroundClassName = selected ? ' bg-blue-100 dark:bg-neutral-700' : '' const unreadClassName = email.unread ? ' font-bold' : ' dark:font-light' const draftEmailsContext = useContext(DraftEmailsContext) @@ -33,61 +32,76 @@ export default function EmailTableRow(props: EmailTableRowProps) { }) } - const isMacLike = /(Mac|iPhone|iPod|iPad)/i.test(navigator.userAgent) + const openEmail = () => { + if (email.type === 'draft') { + if (email.threadID) { + navigate(`/inbox/thread/${email.threadID}`) + return + } + void openDraftEmail(email.messageID) + } else if (email.type === 'inbox' || email.type === 'sent') { + if (email.threadID) { + navigate(`/inbox/thread/${email.threadID}`) + return + } + navigate(`/inbox/${email.messageID}`) + } + } return ( -
{ - const shouldAdd = - (isMacLike && event.metaKey) || (!isMacLike && event.ctrlKey) - if (isMacLike) onClick(shouldAdd ? 'add' : 'replace') - }} - onDoubleClick={() => { - if (email.type === 'draft') { - if (email.threadID) { - navigate(`/inbox/thread/${email.threadID}`) - return - } - void openDraftEmail(email.messageID) - } else if (email.type === 'inbox' || email.type === 'sent') { - if (email.threadID) { - navigate(`/inbox/thread/${email.threadID}`) - return - } - navigate(`/inbox/${email.messageID}`) +
+
+ onClick={() => { + onClick() + }} + > + +
+ {selected && } +
+
+
- {email.unread && ( - - )} 0 ? email.from[0] : ''}> {getNameFromEmails(email.from)}
{email.subject}
{formatDate( email.timeReceived || email.timeUpdated || email.timeSent || '', diff --git a/web/src/components/emails/EmailTableView.tsx b/web/src/components/emails/EmailTableView.tsx index 01642bdfb3..a61f016f66 100644 --- a/web/src/components/emails/EmailTableView.tsx +++ b/web/src/components/emails/EmailTableView.tsx @@ -9,7 +9,7 @@ import EmailTableRow from './EmailTableRow' interface EmailTableViewProps { emails: EmailInfo[] selected: string[] - toggleSelected: (messageID: string, action: 'add' | 'replace') => void + toggleSelected: (messageID: string) => void hasMore: boolean loadMoreEmails: () => void } @@ -26,20 +26,15 @@ export default function EmailTableView(props: EmailTableViewProps) { }, [shouldLoadMore]) return ( -
+
{emails.map((email) => { return ( { - toggleSelected(email.messageID, action) + onClick={() => { + toggleSelected(email.messageID) }} /> ) @@ -48,7 +43,7 @@ export default function EmailTableView(props: EmailTableViewProps) {
diff --git a/web/src/pages/EmailList.tsx b/web/src/pages/EmailList.tsx index 1355a2e82d..873368d6f0 100644 --- a/web/src/pages/EmailList.tsx +++ b/web/src/pages/EmailList.tsx @@ -44,12 +44,7 @@ export default function EmailList() { emailViewRef.current?.scrollTo(0, scrollYPosition) }, [emailViewRef.current]) - const toggleSelected = (messageID: string, action: 'add' | 'replace') => { - if (action === 'replace') { - setSelected([messageID]) - return - } - + const toggleSelected = (messageID: string) => { if (selected.includes(messageID)) { setSelected(selected.filter((s) => s !== messageID)) } else { diff --git a/web/src/pages/EmailRawView.tsx b/web/src/pages/EmailRawView.tsx index 1af551de62..bf23a659f0 100644 --- a/web/src/pages/EmailRawView.tsx +++ b/web/src/pages/EmailRawView.tsx @@ -47,7 +47,7 @@ export default function EmailRawView() {
- Loading...
}> + Loading...
}> {(raw: string) => ( <> diff --git a/web/src/pages/EmailView.tsx b/web/src/pages/EmailView.tsx index 86e10bda85..14229a2357 100644 --- a/web/src/pages/EmailView.tsx +++ b/web/src/pages/EmailView.tsx @@ -213,7 +213,7 @@ export default function EmailView() { - Loading... + Loading...
} >