Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9239e6ecc5 | ||
|
|
8bb284e1d3 | ||
|
|
52fc678e44 | ||
|
|
136c269935 |
@@ -41,13 +41,11 @@ export const createBoardContentPage = <TParams extends Record<string, unknown>>(
|
|||||||
}),
|
}),
|
||||||
// eslint-disable-next-line no-restricted-syntax
|
// eslint-disable-next-line no-restricted-syntax
|
||||||
page: async ({ params }: { params: Promise<TParams> }) => {
|
page: async ({ params }: { params: Promise<TParams> }) => {
|
||||||
const session = await auth();
|
const resolvedParams = await params;
|
||||||
const integrations = await getIntegrationsWithPermissionsAsync(session);
|
|
||||||
|
|
||||||
const board = await getInitialBoard(await params);
|
|
||||||
const queryClient = getQueryClient();
|
const queryClient = getQueryClient();
|
||||||
|
|
||||||
// Prefetch item data
|
const [board, session] = await Promise.all([getInitialBoard(resolvedParams), auth()]);
|
||||||
|
|
||||||
const itemsMap = board.items.reduce((acc, item) => {
|
const itemsMap = board.items.reduce((acc, item) => {
|
||||||
const existing = acc.get(item.kind);
|
const existing = acc.get(item.kind);
|
||||||
if (existing) {
|
if (existing) {
|
||||||
@@ -58,17 +56,20 @@ export const createBoardContentPage = <TParams extends Record<string, unknown>>(
|
|||||||
return acc;
|
return acc;
|
||||||
}, new Map<WidgetKind, Item[]>());
|
}, new Map<WidgetKind, Item[]>());
|
||||||
|
|
||||||
for (const [kind, items] of itemsMap) {
|
const [integrations] = await Promise.all([
|
||||||
await prefetchForKindAsync(kind, queryClient, items).catch((error) => {
|
getIntegrationsWithPermissionsAsync(session),
|
||||||
logger.error(
|
...Array.from(itemsMap).map(([kind, items]) =>
|
||||||
new ErrorWithMetadata(
|
prefetchForKindAsync(kind, queryClient, items).catch((error) => {
|
||||||
"Failed to prefetch widget",
|
logger.error(
|
||||||
{ widgetKind: kind, itemCount: items.length },
|
new ErrorWithMetadata(
|
||||||
{ cause: error },
|
"Failed to prefetch widget",
|
||||||
),
|
{ widgetKind: kind, itemCount: items.length },
|
||||||
);
|
{ cause: error },
|
||||||
});
|
),
|
||||||
}
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
<HydrationBoundary state={dehydrate(queryClient)}>
|
||||||
|
|||||||
Reference in new issue
Block a user