mirror of
https://github.com/karakeep-app/karakeep.git
synced 2026-10-20 05:18:36 +02:00
* Add initial impl * fix some format inconsistencies, add indicator in user settings when local is out of sync * Fix sliders in user settings, unify constants and formatting * address CodeRabbit suggestions * add mobile implementation * address coderabbit nitpicks * fix responsiveness of the reader settings popover * Move more of the web UI strings to i18n * update translations for more coverage * remove duplicate logic/definitions * fix android font family * add shared reading setting hook between web and mobile * unify reader settings context for both web and mobile * remove unused export * address coderabbit suggestions * fix tests
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import { redirect } from "next/navigation";
|
|
import { ReaderSettingsProvider } from "@/lib/readerSettings";
|
|
import { UserSettingsContextProvider } from "@/lib/userSettings";
|
|
import { api } from "@/server/api/client";
|
|
import { getServerAuthSession } from "@/server/auth";
|
|
import { TRPCError } from "@trpc/server";
|
|
|
|
import { tryCatch } from "@karakeep/shared/tryCatch";
|
|
|
|
export default async function ReaderLayout({
|
|
children,
|
|
}: Readonly<{
|
|
children: React.ReactNode;
|
|
}>) {
|
|
const session = await getServerAuthSession();
|
|
if (!session) {
|
|
redirect("/");
|
|
}
|
|
|
|
const userSettings = await 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;
|
|
}
|
|
|
|
return (
|
|
<UserSettingsContextProvider userSettings={userSettings.data}>
|
|
<ReaderSettingsProvider>{children}</ReaderSettingsProvider>
|
|
</UserSettingsContextProvider>
|
|
);
|
|
}
|