-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #304 from elie222/email-side-panel
View emails in side panel
- Loading branch information
Showing
22 changed files
with
299 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
"use client"; | ||
|
||
import { useCallback } from "react"; | ||
import { Sheet, SheetContent } from "@/components/ui/sheet"; | ||
import { useDisplayedEmail } from "@/hooks/useDisplayedEmail"; | ||
import { EmailThread } from "@/components/email-list/EmailPanel"; | ||
import { useThread } from "@/hooks/useThread"; | ||
import { LoadingContent } from "@/components/LoadingContent"; | ||
import { ErrorBoundary } from "@/components/ErrorBoundary"; | ||
|
||
export function EmailViewer() { | ||
const { threadId, showEmail } = useDisplayedEmail(); | ||
|
||
const hideEmail = useCallback(() => showEmail(null), [showEmail]); | ||
|
||
return ( | ||
<Sheet open={!!threadId} onOpenChange={hideEmail}> | ||
<SheetContent | ||
side="right" | ||
size="5xl" | ||
className="overflow-y-auto p-0" | ||
overlay="transparent" | ||
> | ||
{threadId && <EmailContent threadId={threadId} />} | ||
</SheetContent> | ||
</Sheet> | ||
); | ||
} | ||
|
||
function EmailContent({ threadId }: { threadId: string }) { | ||
const { data, isLoading, error, mutate } = useThread({ id: threadId }); | ||
|
||
return ( | ||
<ErrorBoundary extra={{ component: "EmailContent", threadId }}> | ||
<LoadingContent loading={isLoading} error={error}> | ||
{data && ( | ||
<EmailThread | ||
messages={data.thread.messages} | ||
refetch={mutate} | ||
showReplyButton={false} | ||
/> | ||
)} | ||
</LoadingContent> | ||
</ErrorBoundary> | ||
); | ||
} |
Oops, something went wrong.