Skip to content

Commit

Permalink
Add error boundary
Browse files Browse the repository at this point in the history
  • Loading branch information
elie222 committed Jan 11, 2025
1 parent 56f0914 commit 5915174
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions apps/web/components/EmailViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ 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();
Expand All @@ -30,14 +31,16 @@ function EmailContent({ threadId }: { threadId: string }) {
const { data, isLoading, error, mutate } = useThread({ id: threadId });

return (
<LoadingContent loading={isLoading} error={error}>
{data && (
<EmailThread
messages={data.thread.messages}
refetch={mutate}
showReplyButton={false}
/>
)}
</LoadingContent>
<ErrorBoundary extra={{ component: "EmailContent", threadId }}>
<LoadingContent loading={isLoading} error={error}>
{data && (
<EmailThread
messages={data.thread.messages}
refetch={mutate}
showReplyButton={false}
/>
)}
</LoadingContent>
</ErrorBoundary>
);
}

0 comments on commit 5915174

Please sign in to comment.