aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web
diff options
context:
space:
mode:
authorMohamed Bassem <me@mbassem.com>2025-09-14 11:57:11 +0000
committerMohamed Bassem <me@mbassem.com>2025-09-14 11:57:11 +0000
commit92e357f141ff2aa4730e4a6ec316b7524fec863a (patch)
tree444ce72098b87b45399fd548c61be265c1ca884e /apps/web
parentd53b28261cecdb093128f59acf15af3e7919d3ca (diff)
downloadkarakeep-92e357f141ff2aa4730e4a6ec316b7524fec863a.tar.zst
fix(web): Handle user deletion more gracefully
Diffstat (limited to 'apps/web')
-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} />
</>
}
/>