Files
sendou.ink/app/features/layout/core/layout.server.ts

18 lines
778 B
TypeScript

import type { AuthenticatedUser } from "~/features/auth/core/user.server";
import { resolveGlobalStatus } from "~/features/global-status/core/global-status.server";
import { resolveSidebarData } from "~/features/sidebar/core/sidebar.server";
import { GIT_COMMIT } from "~/utils/git-commit";
/**
* App shell data that goes stale while a page sits open; shared by the root loader and the route
* `LayoutDataProvider` polls so they can't drift. Notifications have their own route (`NotificationsProvider`).
*/
export async function resolveLayoutData(user: AuthenticatedUser | undefined) {
return {
loggedInUserId: user?.id ?? null,
sidebar: await resolveSidebarData(user),
globalStatus: user ? await resolveGlobalStatus(user.id) : null,
buildCommit: GIT_COMMIT,
};
}