Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
163 commits
Select commit Hold shift + click to select a range
3c91c12
adjustable height
nizzyabi Mar 24, 2025
009ad18
h1 h2 h3 working in reply composer
nizzyabi Mar 24, 2025
db00358
select dropdown for categories
nizzyabi Mar 24, 2025
1650306
feat(navbar): update item label based on auth status
pietrodev07 Mar 25, 2025
2463442
feature/persist user settings (#513)
sergioxro Mar 25, 2025
8b63b6a
remove unique status from email in schema
nizzyabi Mar 25, 2025
d825d3a
early access check added to schema
nizzyabi Mar 25, 2025
935a243
Merge pull request #515 from Mail-0/early-access-generate
MrgSub Mar 25, 2025
63bccd5
Merge pull request #514 from pietrodev07/feature/auth-navbar
MrgSub Mar 25, 2025
0f9c50f
updated readme
ahmetskilinc Mar 25, 2025
a1d0cd1
add contributors
ahmetskilinc Mar 25, 2025
4f66da8
remove text-decoration
ahmetskilinc Mar 25, 2025
2b96a33
text-decoration
ahmetskilinc Mar 25, 2025
ca7566e
Merge pull request #518 from Mail-0/update-readme
MrgSub Mar 25, 2025
de4231d
remove auto focus on search
nizzyabi Mar 26, 2025
f035da1
ahuh
hiheyhello123 Mar 26, 2025
c3887fd
gg
hiheyhello123 Mar 26, 2025
e3d1f79
i18n
hiheyhello123 Mar 26, 2025
62cc85c
Merge pull request #521 from Mail-0/keyboard-navigation
MrgSub Mar 26, 2025
aa44450
check email for early access (#519)
nizzyabi Mar 26, 2025
ad33458
saving...
MrgSub Mar 26, 2025
36f32db
disable buttons
hiheyhello123 Mar 26, 2025
d2af50b
disable
hiheyhello123 Mar 26, 2025
4428e40
fix
hiheyhello123 Mar 26, 2025
a6542c0
Merge pull request #522 from Mail-0/keyboard-navigation
MrgSub Mar 26, 2025
896b3d1
saving...
MrgSub Mar 26, 2025
ae89f43
saving...
MrgSub Mar 26, 2025
6b9b375
minor
hiheyhello123 Mar 26, 2025
08d8708
New translations en.json (French)
longgoneaccount Mar 26, 2025
aadb91e
New translations en.json (Spanish)
longgoneaccount Mar 26, 2025
4abd921
New translations en.json (Arabic)
longgoneaccount Mar 26, 2025
2a129eb
New translations en.json (Catalan)
longgoneaccount Mar 26, 2025
bce69ec
New translations en.json (Czech)
longgoneaccount Mar 26, 2025
da88c85
New translations en.json (German)
longgoneaccount Mar 26, 2025
ebfa0ee
New translations en.json (Japanese)
longgoneaccount Mar 26, 2025
1d583dc
New translations en.json (Korean)
longgoneaccount Mar 26, 2025
9eb54d0
New translations en.json (Polish)
longgoneaccount Mar 26, 2025
be430b9
New translations en.json (Portuguese)
longgoneaccount Mar 26, 2025
29d54f2
New translations en.json (Russian)
longgoneaccount Mar 26, 2025
fc796d6
New translations en.json (Turkish)
longgoneaccount Mar 26, 2025
c75928f
New translations en.json (Latvian)
longgoneaccount Mar 26, 2025
791ca29
New translations en.json (Hindi)
longgoneaccount Mar 26, 2025
3917ef7
Merge branch 'staging' into l10n_staging
hiheyhello123 Mar 26, 2025
4c5bc02
Merge pull request #524 from Mail-0/l10n_staging
hiheyhello123 Mar 26, 2025
3a6add5
New translations en.json (French)
longgoneaccount Mar 26, 2025
b043d57
New translations en.json (Spanish)
longgoneaccount Mar 26, 2025
283a349
New translations en.json (Arabic)
longgoneaccount Mar 26, 2025
44adb78
New translations en.json (Catalan)
longgoneaccount Mar 26, 2025
a5fe315
New translations en.json (German)
longgoneaccount Mar 26, 2025
6ab1d00
New translations en.json (Japanese)
longgoneaccount Mar 26, 2025
480abb8
New translations en.json (Korean)
longgoneaccount Mar 26, 2025
7cde6c7
New translations en.json (Polish)
longgoneaccount Mar 26, 2025
2eb76b0
New translations en.json (Portuguese)
longgoneaccount Mar 26, 2025
05d268f
New translations en.json (Hindi)
longgoneaccount Mar 26, 2025
bdb80a0
Merge pull request #525 from Mail-0/l10n_staging
hiheyhello123 Mar 27, 2025
3610590
reply and searchbar display
nizzyabi Mar 27, 2025
76cf73a
reply ai (#526)
hiheyhello123 Mar 27, 2025
f9d480a
Autocompletions for reply and create
ahmetskilinc Mar 27, 2025
8467178
email avatars (#528)
ahmetskilinc Mar 28, 2025
0c48dd0
color fix
nizzyabi Mar 28, 2025
1c5abee
reply ui
nizzyabi Mar 28, 2025
6ec4b21
New translations en.json (Japanese)
longgoneaccount Mar 28, 2025
7d0c8ed
New translations en.json (Korean)
longgoneaccount Mar 28, 2025
a7a4961
Merge branch 'staging' into l10n_staging
hiheyhello123 Mar 28, 2025
e4feaef
Merge pull request #532 from Mail-0/l10n_staging
hiheyhello123 Mar 28, 2025
9c799ab
additions
nizzyabi Mar 29, 2025
fb4d84e
no drop down
nizzyabi Mar 29, 2025
a58af70
ui fix
nizzyabi Mar 29, 2025
4c7506c
wip performance
MrgSub Mar 29, 2025
02f6b64
Merge branch 'staging' of https://github.com/nizzyabi/mail into staging
MrgSub Mar 29, 2025
7d048fd
saving...
MrgSub Mar 29, 2025
76c055d
saving...
MrgSub Mar 29, 2025
d37cfb6
saving...
MrgSub Mar 29, 2025
f39133a
saving...
MrgSub Mar 29, 2025
fea94e9
- updated phrases
ahmetskilinc Mar 29, 2025
6d4aaee
Improved ai with custom prompt (#534)
nizzyabi Mar 29, 2025
f35a215
removed new lines
ahmetskilinc Mar 29, 2025
0acebde
Merge branch 'staging' of github.com:Mail-0/Mail-0 into feat/autocomp…
ahmetskilinc Mar 29, 2025
c58763a
empty commit
nizzyabi Mar 29, 2025
92cfb27
search
nizzyabi Mar 30, 2025
e6d9614
forwarding
nizzyabi Mar 30, 2025
5509cc3
search filter removed. all in ai now
nizzyabi Mar 30, 2025
04c2793
Merge pull request #529 from Mail-0/feat/autocomplete-sentences
MrgSub Mar 30, 2025
e81eb16
saving...
MrgSub Mar 30, 2025
60bb994
fix double submit on command enter create email
nizzyabi Mar 30, 2025
e2f86b4
saving...
MrgSub Mar 30, 2025
7cf79cd
Merge branch 'main' into staging
MrgSub Mar 30, 2025
8227bd4
saving...
MrgSub Mar 30, 2025
915a64a
turn search ai into a server action
nizzyabi Mar 30, 2025
e641e61
fuix
nizzyabi Mar 30, 2025
21ea59a
show most recent email in thread
nizzyabi Mar 31, 2025
49b0f47
saving...
MrgSub Mar 31, 2025
88afd15
saving...
MrgSub Mar 31, 2025
bbe58fd
forward and reply in one compose button
nizzyabi Mar 31, 2025
011723f
saving...
MrgSub Mar 31, 2025
8206dba
Merge branch 'staging' of https://github.com/nizzyabi/mail into staging
MrgSub Mar 31, 2025
a7d3459
New translations en.json (French)
longgoneaccount Mar 31, 2025
1a6242d
New translations en.json (Spanish)
longgoneaccount Mar 31, 2025
d65355b
New translations en.json (Arabic)
longgoneaccount Mar 31, 2025
d811bf2
New translations en.json (Catalan)
longgoneaccount Mar 31, 2025
e6c52a5
New translations en.json (Czech)
longgoneaccount Mar 31, 2025
a115b8c
New translations en.json (German)
longgoneaccount Mar 31, 2025
8e422b1
New translations en.json (Japanese)
longgoneaccount Mar 31, 2025
44459cd
New translations en.json (Korean)
longgoneaccount Mar 31, 2025
894e6b4
New translations en.json (Polish)
longgoneaccount Mar 31, 2025
b431919
New translations en.json (Portuguese)
longgoneaccount Mar 31, 2025
f07a124
New translations en.json (Russian)
longgoneaccount Mar 31, 2025
bcf938c
New translations en.json (Turkish)
longgoneaccount Mar 31, 2025
cb8d613
New translations en.json (Latvian)
longgoneaccount Mar 31, 2025
8e7e21d
New translations en.json (Hindi)
longgoneaccount Mar 31, 2025
92ebb62
Merge branch 'staging' into l10n_staging
hiheyhello123 Mar 31, 2025
241620c
Merge pull request #536 from Mail-0/l10n_staging
hiheyhello123 Mar 31, 2025
f26a5a6
fix to height reply composer
nizzyabi Mar 31, 2025
bc3f331
posthog
nizzyabi Apr 1, 2025
5f3ab80
remove github login for now
nizzyabi Apr 1, 2025
9aec782
refresh
nizzyabi Apr 1, 2025
995a757
New translations en.json (French)
longgoneaccount Apr 1, 2025
93d5d63
New translations en.json (Spanish)
longgoneaccount Apr 1, 2025
c4196a0
New translations en.json (Arabic)
longgoneaccount Apr 1, 2025
10e7b4a
New translations en.json (Catalan)
longgoneaccount Apr 1, 2025
87460cc
New translations en.json (Czech)
longgoneaccount Apr 1, 2025
7008d86
New translations en.json (German)
longgoneaccount Apr 1, 2025
61ec8df
New translations en.json (Japanese)
longgoneaccount Apr 1, 2025
f717673
New translations en.json (Korean)
longgoneaccount Apr 1, 2025
f11f908
New translations en.json (Polish)
longgoneaccount Apr 1, 2025
03d567e
New translations en.json (Portuguese)
longgoneaccount Apr 1, 2025
b8291e0
New translations en.json (Russian)
longgoneaccount Apr 1, 2025
c71971d
New translations en.json (Turkish)
longgoneaccount Apr 1, 2025
bce0071
New translations en.json (Latvian)
longgoneaccount Apr 1, 2025
93a8f3b
New translations en.json (Hindi)
longgoneaccount Apr 1, 2025
532d326
Merge pull request #538 from Mail-0/l10n_staging
hiheyhello123 Apr 1, 2025
0bec8bf
revert
hiheyhello123 Apr 1, 2025
e57ddb5
Merge branch 'staging' of https://github.com/Mail-0/Zero into staging
hiheyhello123 Apr 1, 2025
1f1714a
a
hiheyhello123 Apr 1, 2025
99d8671
fix load more
nizzyabi Apr 1, 2025
f04c5aa
Merge branch 'staging' of https://github.com/Mail-0/Zero into staging
hiheyhello123 Apr 1, 2025
e0226dd
fix load more
hiheyhello123 Apr 1, 2025
eb334c5
remove use memo from thread to not load when opening an email
nizzyabi Apr 1, 2025
ee6aa05
fix switching accounts
hiheyhello123 Apr 1, 2025
0d6e42c
Merge branch 'staging' of https://github.com/Mail-0/Zero into staging
hiheyhello123 Apr 1, 2025
6f15faa
navbar changed to login
nizzyabi Apr 1, 2025
b785aea
fix
nizzyabi Apr 1, 2025
70ab238
New translations en.json (French)
longgoneaccount Apr 1, 2025
c79a0ab
New translations en.json (French)
longgoneaccount Apr 1, 2025
6743331
New translations en.json (Spanish)
longgoneaccount Apr 1, 2025
69ccb2d
New translations en.json (Arabic)
longgoneaccount Apr 1, 2025
959086d
New translations en.json (Catalan)
longgoneaccount Apr 1, 2025
4d78ae1
New translations en.json (Czech)
longgoneaccount Apr 1, 2025
4781126
New translations en.json (German)
longgoneaccount Apr 1, 2025
e270c57
New translations en.json (Japanese)
longgoneaccount Apr 1, 2025
89e1f49
New translations en.json (Korean)
longgoneaccount Apr 1, 2025
21e47cf
New translations en.json (Polish)
longgoneaccount Apr 1, 2025
3f9aef0
New translations en.json (Portuguese)
longgoneaccount Apr 1, 2025
4b95a07
New translations en.json (Russian)
longgoneaccount Apr 1, 2025
f56d9cb
New translations en.json (Turkish)
longgoneaccount Apr 1, 2025
fea3c49
New translations en.json (Latvian)
longgoneaccount Apr 1, 2025
3db9a99
New translations en.json (Hindi)
longgoneaccount Apr 1, 2025
e9b7a88
Merge pull request #540 from Mail-0/l10n_staging
hiheyhello123 Apr 1, 2025
474ef59
fix mail demo
hiheyhello123 Apr 1, 2025
28f50be
Merge pull request #543 from Mail-0/fix-alpha
hiheyhello123 Apr 1, 2025
95633fa
fix auth
hiheyhello123 Apr 1, 2025
2b5709b
Merge pull request #545 from Mail-0/fix-alpha
ahmetskilinc Apr 1, 2025
c21c220
Merge branch 'main' of github.com:Mail-0/Mail-0 into staging
ahmetskilinc Apr 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions apps/mail/app/(routes)/create/layout.tsx

This file was deleted.

11 changes: 0 additions & 11 deletions apps/mail/app/(routes)/create/page.tsx

This file was deleted.

10 changes: 10 additions & 0 deletions apps/mail/app/(routes)/mail/[folder]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { MailLayout } from '@/components/mail/mail';
import { redirect } from 'next/navigation';
import { auth } from '@/lib/auth';
import { headers } from 'next/headers';

interface MailPageProps {
params: Promise<{
Expand All @@ -9,6 +12,13 @@ interface MailPageProps {
const ALLOWED_FOLDERS = ['inbox', 'draft', 'sent', 'spam', 'trash', 'archive'];

export default async function MailPage({ params }: MailPageProps) {
const headersList = await headers();
const session = await auth.api.getSession({ headers: headersList });

if (!session) {
redirect('/');
}

const { folder } = await params;

if (!ALLOWED_FOLDERS.includes(folder)) {
Expand Down
12 changes: 11 additions & 1 deletion apps/mail/app/(routes)/mail/create/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import { CreateEmail } from '@/components/create/create-email';
import { auth } from '@/lib/auth';
import { headers } from 'next/headers';
import { redirect } from 'next/navigation';

export default async function CreatePage() {
const headersList = await headers();
const session = await auth.api.getSession({ headers: headersList });

if (!session) {
redirect('/');
}

export default function CreatePage() {
return (
<div className="flex h-full w-full flex-col">
<div className="h-full flex-1">
Expand Down
241 changes: 164 additions & 77 deletions apps/mail/components/mail/mail-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,105 +135,192 @@ const Thread = memo(

return (
<div className="p-1" onClick={onClick ? onClick(message) : undefined}>
<Link
href={`/mail/${folder}?threadId=${message.threadId ?? message.id}`}
data-thread-id={message.threadId ?? message.id}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
key={message.threadId ?? message.id}
className={cn(
'hover:bg-offsetLight hover:bg-primary/5 group relative flex cursor-pointer flex-col items-start overflow-clip rounded-lg border border-transparent px-4 py-3 text-left text-sm transition-all hover:opacity-100',
isMailSelected || (!message.unread && 'opacity-50'),
(isMailSelected || isMailBulkSelected || isKeyboardFocused) &&
'border-border bg-primary/5 opacity-100',
isKeyboardFocused && 'ring-primary/50 ring-2',
)}
>
{demo ? (
<div
data-thread-id={message.threadId ?? message.id}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
key={message.threadId ?? message.id}
className={cn(
'bg-primary absolute inset-y-0 left-0 w-1 -translate-x-2 transition-transform ease-out',
isMailBulkSelected && 'translate-x-0',
'hover:bg-offsetLight hover:bg-primary/5 group relative flex cursor-pointer flex-col items-start overflow-clip rounded-lg border border-transparent px-4 py-3 text-left text-sm transition-all hover:opacity-100',
isMailSelected || (!message.unread && 'opacity-50'),
(isMailSelected || isMailBulkSelected || isKeyboardFocused) &&
'border-border bg-primary/5 opacity-100',
isKeyboardFocused && 'ring-primary/50 ring-2',
)}
/>
{/* <MailQuickActions
message={message}
isHovered={isHovered || isKeyboardFocused}
isInQuickActionMode={isInQuickActionMode}
selectedQuickActionIndex={selectedQuickActionIndex}
resetNavigation={resetNavigation}
/> */}
<div className="flex w-full items-center justify-between gap-4">
<Avatar className="h-8 w-8 rounded-full">
<AvatarImage src={getEmailLogo(message.sender.email)} className="rounded-full" />
<AvatarFallback className="rounded-full">{message.sender.name[0]}</AvatarFallback>
</Avatar>
<div className="flex w-full justify-between">
<div className="w-full">
<div className="flex w-full flex-row items-center justify-between">
<div className="flex flex-row items-center gap-1">
<p
className={cn(
message.unread && !isMailSelected ? 'font-bold' : 'font-medium',
'text-md flex items-baseline gap-1 group-hover:opacity-100',
)}
>
<span>{highlightText(message.sender.name, searchValue.highlight)}</span>{' '}
{message.unread && !isMailSelected ? (
<span className="size-2 rounded bg-[#006FFE]" />
>
<div
className={cn(
'bg-primary absolute inset-y-0 left-0 w-1 -translate-x-2 transition-transform ease-out',
isMailBulkSelected && 'translate-x-0',
)}
/>
<div className="flex w-full items-center justify-between gap-4">
<Avatar className="h-8 w-8 rounded-full">
<AvatarImage src={getEmailLogo(message.sender.email)} className="rounded-full" />
<AvatarFallback className="rounded-full">{message.sender.name[0]}</AvatarFallback>
</Avatar>
<div className="flex w-full justify-between">
<div className="w-full">
<div className="flex w-full flex-row items-center justify-between">
<div className="flex flex-row items-center gap-1">
<p
className={cn(
message.unread && !isMailSelected ? 'font-bold' : 'font-medium',
'text-md flex items-baseline gap-1 group-hover:opacity-100',
)}
>
<span>{highlightText(message.sender.name, searchValue.highlight)}</span>{' '}
{message.unread && !isMailSelected ? (
<span className="size-2 rounded bg-[#006FFE]" />
) : null}
</p>
<MailLabels labels={threadLabels} />
{message.totalReplies > 1 ? (
<Tooltip>
<TooltipTrigger asChild>
<span className="rounded-md border border-dotted px-[5px] py-[1px] text-xs opacity-70">
{message.totalReplies}
</span>
</TooltipTrigger>
<TooltipContent className="px-1 py-0 text-xs">
{t('common.mail.replies', { count: message.totalReplies })}
</TooltipContent>
</Tooltip>
) : null}
</p>
<MailLabels labels={threadLabels} />
{message.totalReplies > 1 ? (
<Tooltip>
<TooltipTrigger asChild>
<span className="rounded-md border border-dotted px-[5px] py-[1px] text-xs opacity-70">
{message.totalReplies}
</span>
</TooltipTrigger>
<TooltipContent className="px-1 py-0 text-xs">
{t('common.mail.replies', { count: message.totalReplies })}
</TooltipContent>
</Tooltip>
</div>
{message.receivedOn ? (
<p
className={cn(
'text-nowrap text-xs font-normal opacity-70 transition-opacity group-hover:opacity-100',
isMailSelected && 'opacity-100',
)}
>
{formatDate(message.receivedOn.split('.')[0] || '')}
</p>
) : null}
</div>
{message.receivedOn ? (
<p
className={cn(
'text-nowrap text-xs font-normal opacity-70 transition-opacity group-hover:opacity-100',
isMailSelected && 'opacity-100',
)}
>
{formatDate(message.receivedOn.split('.')[0] || '')}
</p>
) : null}
<p
className={cn(
'mt-1 line-clamp-1 text-xs opacity-70 transition-opacity',
mail.selected ? 'line-clamp-1' : 'line-clamp-2',
isMailSelected && 'opacity-100',
)}
>
{highlightText(message.subject, searchValue.highlight)}
</p>
</div>
<p
className={cn(
'mt-1 line-clamp-1 text-xs opacity-70 transition-opacity',
mail.selected ? 'line-clamp-1' : 'line-clamp-2',
isMailSelected && 'opacity-100',
)}
>
{highlightText(message.subject, searchValue.highlight)}
</p>
</div>
</div>
</div>
</Link>
) : (
<Link
href={`/mail/${folder}?threadId=${message.threadId ?? message.id}`}
data-thread-id={message.threadId ?? message.id}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
key={message.threadId ?? message.id}
className={cn(
'hover:bg-offsetLight hover:bg-primary/5 group relative flex cursor-pointer flex-col items-start overflow-clip rounded-lg border border-transparent px-4 py-3 text-left text-sm transition-all hover:opacity-100',
isMailSelected || (!message.unread && 'opacity-50'),
(isMailSelected || isMailBulkSelected || isKeyboardFocused) &&
'border-border bg-primary/5 opacity-100',
isKeyboardFocused && 'ring-primary/50 ring-2',
)}
>
<div
className={cn(
'bg-primary absolute inset-y-0 left-0 w-1 -translate-x-2 transition-transform ease-out',
isMailBulkSelected && 'translate-x-0',
)}
/>
<div className="flex w-full items-center justify-between gap-4">
<Avatar className="h-8 w-8 rounded-full">
<AvatarImage src={getEmailLogo(message.sender.email)} className="rounded-full" />
<AvatarFallback className="rounded-full">{message.sender.name[0]}</AvatarFallback>
</Avatar>
<div className="flex w-full justify-between">
<div className="w-full">
<div className="flex w-full flex-row items-center justify-between">
<div className="flex flex-row items-center gap-1">
<p
className={cn(
message.unread && !isMailSelected ? 'font-bold' : 'font-medium',
'text-md flex items-baseline gap-1 group-hover:opacity-100',
)}
>
<span>{highlightText(message.sender.name, searchValue.highlight)}</span>{' '}
{message.unread && !isMailSelected ? (
<span className="size-2 rounded bg-[#006FFE]" />
) : null}
</p>
<MailLabels labels={threadLabels} />
{message.totalReplies > 1 ? (
<Tooltip>
<TooltipTrigger asChild>
<span className="rounded-md border border-dotted px-[5px] py-[1px] text-xs opacity-70">
{message.totalReplies}
</span>
</TooltipTrigger>
<TooltipContent className="px-1 py-0 text-xs">
{t('common.mail.replies', { count: message.totalReplies })}
</TooltipContent>
</Tooltip>
) : null}
</div>
{message.receivedOn ? (
<p
className={cn(
'text-nowrap text-xs font-normal opacity-70 transition-opacity group-hover:opacity-100',
isMailSelected && 'opacity-100',
)}
>
{formatDate(message.receivedOn.split('.')[0] || '')}
</p>
) : null}
</div>
<p
className={cn(
'mt-1 line-clamp-1 text-xs opacity-70 transition-opacity',
mail.selected ? 'line-clamp-1' : 'line-clamp-2',
isMailSelected && 'opacity-100',
)}
>
{highlightText(message.subject, searchValue.highlight)}
</p>
</div>
</div>
</div>
</Link>
)}
</div>
);
},
);

Thread.displayName = 'Thread';

export function MailListDemo({ items: filteredItems = items }) {
export function MailListDemo({
items: filteredItems = items,
onSelectMail,
}: {
items?: typeof items;
onSelectMail?: (message: any) => void;
}) {
return (
<ScrollArea className="h-full pb-2" type="scroll">
<div className={cn('relative min-h-[calc(100vh-4rem)] w-full')}>
<div className="absolute left-0 top-0 w-full p-[8px]">
{filteredItems.map((item) => {
return item ? <Thread demo key={item.id} message={item} selectMode={'single'} /> : null;
return item ? (
<Thread
demo
key={item.id}
message={item}
selectMode={'single'}
onClick={(message) => () => onSelectMail && onSelectMail(message)}
/>
) : null;
})}
</div>
</div>
Expand Down
18 changes: 15 additions & 3 deletions apps/mail/components/mail/mail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import { handleUnsubscribe } from '@/lib/email-utils.client';
import { useParams, useSearchParams } from 'next/navigation';
import { useMediaQuery } from '../../hooks/use-media-query';
import { useSearchValue } from '@/hooks/use-search-value';
import { RefreshIcon } from '../icons/animated/refresh';
import { SearchIcon } from '../icons/animated/search';
import { useMail } from '@/components/mail/use-mail';
import { SidebarToggle } from '../ui/sidebar-toggle';
Expand All @@ -68,13 +69,13 @@ import { SearchBar } from './search-bar';
import items from './demo.json';
import { useAtom } from 'jotai';
import { toast } from 'sonner';
import { RefreshIcon } from '../icons/animated/refresh';

export function DemoMailLayout() {
const [mail, setMail] = useState({
selected: 'demo',
bulkSelected: [],
});
const [selectedMail, setSelectedMail] = useState<any>(null);
const isMobile = false;
const isValidating = false;
const isLoading = false;
Expand All @@ -84,6 +85,11 @@ export function DemoMailLayout() {
const [activeCategory, setActiveCategory] = useState('Primary');
const [filteredItems, setFilteredItems] = useState(items);

const handleSelectMail = useCallback((message: any) => {
setSelectedMail(message);
setMail((prev) => ({ ...prev, selected: message.id }));
}, []);

useEffect(() => {
if (activeCategory === 'Primary') {
setFilteredItems(items);
Expand All @@ -101,6 +107,12 @@ export function DemoMailLayout() {
}
}, [activeCategory]);

useEffect(() => {
if (filteredItems.length > 0 && !selectedMail) {
handleSelectMail(filteredItems[0]);
}
}, [filteredItems, selectedMail, handleSelectMail]);

return (
<TooltipProvider delayDuration={0}>
<div className="rounded-inherit flex">
Expand Down Expand Up @@ -162,7 +174,7 @@ export function DemoMailLayout() {
))}
</div>
) : (
<MailListDemo items={filteredItems} />
<MailListDemo items={filteredItems} onSelectMail={handleSelectMail} />
)}
</div>
</div>
Expand All @@ -177,7 +189,7 @@ export function DemoMailLayout() {
minSize={25}
>
<div className="relative hidden h-[calc(100vh-(12px+14px))] max-h-[800px] flex-1 md:block">
<ThreadDemo mail={[filteredItems[0]]} />
<ThreadDemo mail={selectedMail ? [selectedMail] : [filteredItems[0]]} />
</div>
</ResizablePanel>
</>
Expand Down
Loading