aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web/app/dashboard
diff options
context:
space:
mode:
Diffstat (limited to 'apps/web/app/dashboard')
-rw-r--r--apps/web/app/dashboard/layout.tsx26
1 files changed, 22 insertions, 4 deletions
diff --git a/apps/web/app/dashboard/layout.tsx b/apps/web/app/dashboard/layout.tsx
index 1471bfde..911d542c 100644
--- a/apps/web/app/dashboard/layout.tsx
+++ b/apps/web/app/dashboard/layout.tsx
@@ -7,6 +7,7 @@ import { Separator } from "@/components/ui/separator";
import { UserSettingsContextProvider } from "@/lib/userSettings";
import { api } from "@/server/api/client";
import { getServerAuthSession } from "@/server/auth";
+import { TRPCError } from "@trpc/server";
import { TFunction } from "i18next";
import {
Archive,
@@ -18,6 +19,7 @@ import {
} from "lucide-react";
import { PluginManager, PluginType } from "@karakeep/shared/plugins";
+import { tryCatch } from "@karakeep/shared/tryCatch";
export default async function Dashboard({
children,
@@ -32,10 +34,26 @@ export default async function Dashboard({
}
const [lists, userSettings] = await Promise.all([
- api.lists.list(),
- api.users.settings(),
+ tryCatch(api.lists.list()),
+ tryCatch(api.users.settings()),
]);
+ if (userSettings.error) {
+ if (userSettings.error instanceof TRPCError) {
+ if (
+ userSettings.error.code === "NOT_FOUND" ||
+ userSettings.error.code === "UNAUTHORIZED"
+ ) {
+ redirect("/logout");
+ }
+ }
+ throw userSettings.error;
+ }
+
+ if (lists.error) {
+ throw lists.error;
+ }
+
const items = (t: TFunction) =>
[
{
@@ -79,7 +97,7 @@ export default async function Dashboard({
];
return (
- <UserSettingsContextProvider userSettings={userSettings}>
+ <UserSettingsContextProvider userSettings={userSettings.data}>
<SidebarLayout
sidebar={
<Sidebar
@@ -87,7 +105,7 @@ export default async function Dashboard({
extraSections={
<>
<Separator />
- <AllLists initialData={lists} />
+ <AllLists initialData={lists.data} />
</>
}
/>