-
Notifications
You must be signed in to change notification settings - Fork 696
fixed #348 #396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fixed #348 #396
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -21,6 +21,9 @@ import { Button } from "@/components/ui/button"; | |||||||||||||||||||||||||||||||||||||||||
import { findCtaLink } from "@/utils/parse/parseHtml.client"; | ||||||||||||||||||||||||||||||||||||||||||
import { ErrorBoundary } from "@/components/ErrorBoundary"; | ||||||||||||||||||||||||||||||||||||||||||
import { internalDateToDate } from "@/utils/date"; | ||||||||||||||||||||||||||||||||||||||||||
import { Badge } from "@/components/ui/badge"; | ||||||||||||||||||||||||||||||||||||||||||
import { isDefined } from "@/utils/types"; | ||||||||||||||||||||||||||||||||||||||||||
import { useLabels } from "@/hooks/useLabels"; | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
export const EmailListItem = forwardRef( | ||||||||||||||||||||||||||||||||||||||||||
( | ||||||||||||||||||||||||||||||||||||||||||
|
@@ -45,13 +48,25 @@ export const EmailListItem = forwardRef( | |||||||||||||||||||||||||||||||||||||||||
ref: ForwardedRef<HTMLLIElement>, | ||||||||||||||||||||||||||||||||||||||||||
) => { | ||||||||||||||||||||||||||||||||||||||||||
const { thread, splitView, onSelected } = props; | ||||||||||||||||||||||||||||||||||||||||||
const { userLabels } = useLabels(); | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
const lastMessage = thread.messages?.[thread.messages.length - 1]; | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
const isUnread = useMemo(() => { | ||||||||||||||||||||||||||||||||||||||||||
return lastMessage?.labelIds?.includes("UNREAD"); | ||||||||||||||||||||||||||||||||||||||||||
}, [lastMessage?.labelIds]); | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
const labelsToDisplay = useMemo(() => { | ||||||||||||||||||||||||||||||||||||||||||
const labelIds = lastMessage?.labelIds; | ||||||||||||||||||||||||||||||||||||||||||
return labelIds | ||||||||||||||||||||||||||||||||||||||||||
?.map((id) => { | ||||||||||||||||||||||||||||||||||||||||||
const label = userLabels[Number(id)]; | ||||||||||||||||||||||||||||||||||||||||||
if (!label) return null; | ||||||||||||||||||||||||||||||||||||||||||
return { id, name: label.name }; | ||||||||||||||||||||||||||||||||||||||||||
}) | ||||||||||||||||||||||||||||||||||||||||||
.filter(isDefined); | ||||||||||||||||||||||||||||||||||||||||||
}, [lastMessage?.labelIds, userLabels]); | ||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+59
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix the label lookup logic. The current implementation treats const labelsToDisplay = useMemo(() => {
const labelIds = lastMessage?.labelIds;
return labelIds
?.map((id) => {
- const label = userLabels[Number(id)];
+ const label = userLabels.find(label => label.id === id);
if (!label) return null;
return { id, name: label.name };
})
.filter(isDefined);
}, [lastMessage?.labelIds, userLabels]); 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
const preventPropagation = useCallback( | ||||||||||||||||||||||||||||||||||||||||||
(e: React.MouseEvent | React.KeyboardEvent) => e.stopPropagation(), | ||||||||||||||||||||||||||||||||||||||||||
[], | ||||||||||||||||||||||||||||||||||||||||||
|
@@ -138,6 +153,19 @@ export const EmailListItem = forwardRef( | |||||||||||||||||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||||||||||||||||||
<div className="ml-2 min-w-0 overflow-hidden text-foreground"> | ||||||||||||||||||||||||||||||||||||||||||
{lastMessage.headers.subject} | ||||||||||||||||||||||||||||||||||||||||||
{labelsToDisplay && labelsToDisplay.length > 0 && ( | ||||||||||||||||||||||||||||||||||||||||||
<span className="ml-2 inline-flex flex-wrap items-center gap-1"> | ||||||||||||||||||||||||||||||||||||||||||
{labelsToDisplay.map((label) => ( | ||||||||||||||||||||||||||||||||||||||||||
<Badge | ||||||||||||||||||||||||||||||||||||||||||
variant="secondary" | ||||||||||||||||||||||||||||||||||||||||||
key={label.id} | ||||||||||||||||||||||||||||||||||||||||||
className="text-xs" | ||||||||||||||||||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||||||||||||||||||
{label.name} | ||||||||||||||||||||||||||||||||||||||||||
</Badge> | ||||||||||||||||||||||||||||||||||||||||||
))} | ||||||||||||||||||||||||||||||||||||||||||
</span> | ||||||||||||||||||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||
<div className="ml-4 mr-6 flex flex-1 items-center overflow-hidden truncate font-normal leading-5 text-muted-foreground"> | ||||||||||||||||||||||||||||||||||||||||||
{decodedSnippet} | ||||||||||||||||||||||||||||||||||||||||||
|
@@ -195,6 +223,19 @@ export const EmailListItem = forwardRef( | |||||||||||||||||||||||||||||||||||||||||
<div className="mt-1.5 whitespace-nowrap text-sm leading-6"> | ||||||||||||||||||||||||||||||||||||||||||
<div className="min-w-0 overflow-hidden font-medium text-foreground"> | ||||||||||||||||||||||||||||||||||||||||||
{lastMessage.headers.subject} | ||||||||||||||||||||||||||||||||||||||||||
{labelsToDisplay && labelsToDisplay.length > 0 && ( | ||||||||||||||||||||||||||||||||||||||||||
<span className="ml-2 inline-flex flex-wrap items-center gap-1"> | ||||||||||||||||||||||||||||||||||||||||||
{labelsToDisplay.map((label) => ( | ||||||||||||||||||||||||||||||||||||||||||
<Badge | ||||||||||||||||||||||||||||||||||||||||||
variant="secondary" | ||||||||||||||||||||||||||||||||||||||||||
key={label.id} | ||||||||||||||||||||||||||||||||||||||||||
className="text-xs" | ||||||||||||||||||||||||||||||||||||||||||
> | ||||||||||||||||||||||||||||||||||||||||||
{label.name} | ||||||||||||||||||||||||||||||||||||||||||
</Badge> | ||||||||||||||||||||||||||||||||||||||||||
))} | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this appears twice. we could make this a small component at the bottom of this file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||||||||||||||||||||||
</span> | ||||||||||||||||||||||||||||||||||||||||||
)} | ||||||||||||||||||||||||||||||||||||||||||
</div> | ||||||||||||||||||||||||||||||||||||||||||
<div className="mr-6 mt-0.5 flex flex-1 items-center overflow-hidden truncate pl-1 font-normal leading-5 text-muted-foreground"> | ||||||||||||||||||||||||||||||||||||||||||
{decodedSnippet} | ||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we convert to number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise it will be of type any and typescript complains