mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 07:38:33 -06:00
starting to move over settings
This commit is contained in:
@@ -33,7 +33,7 @@ export default async function RootLayout({
|
||||
<MyToaster />
|
||||
<Suspense>
|
||||
<Providers>
|
||||
{children}
|
||||
<DataHydration>{children}</DataHydration>
|
||||
</Providers>
|
||||
</Suspense>
|
||||
</div>
|
||||
@@ -41,3 +41,52 @@ export default async function RootLayout({
|
||||
</html>
|
||||
);
|
||||
}
|
||||
|
||||
async function DataHydration({
|
||||
children,
|
||||
}: Readonly<{
|
||||
children: React.ReactNode;
|
||||
}>) {
|
||||
console.log("starting hydration");
|
||||
const trpcHelper = createServerSideHelpers({
|
||||
router: trpcAppRouter,
|
||||
ctx: createTrpcContext(),
|
||||
transformer: superjson,
|
||||
});
|
||||
const allSettings = await fileStorageService.settings.getAllCoursesSettings();
|
||||
await Promise.all(
|
||||
allSettings.map(async (settings) => {
|
||||
const courseName = settings.name;
|
||||
const moduleNames = await fileStorageService.modules.getModuleNames(
|
||||
courseName
|
||||
);
|
||||
await Promise.all(
|
||||
moduleNames.map(
|
||||
async (moduleName) =>
|
||||
await trpcHelper.assignment.getAllAssignments.prefetch({
|
||||
courseName,
|
||||
moduleName,
|
||||
})
|
||||
)
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
await Promise.all(
|
||||
allSettings.map(
|
||||
async (settings) =>
|
||||
await trpcHelper.lectures.getLectures.prefetch({
|
||||
courseName: settings.name,
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
await hydrateCourses(trpcHelper.queryClient);
|
||||
|
||||
const dehydratedState = dehydrate(trpcHelper.queryClient);
|
||||
console.log("ran hydration");
|
||||
|
||||
return (
|
||||
<HydrationBoundary state={dehydratedState}>{children}</HydrationBoundary>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user