Skip to content

Commit

Permalink
show model content while layout is loading
Browse files Browse the repository at this point in the history
  • Loading branch information
berekuk committed Nov 30, 2024
1 parent 78d0e8b commit 265fcec
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
16 changes: 11 additions & 5 deletions packages/hub/src/app/models/[owner]/[slug]/FallbackLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
"use client";

import { FC } from "react";
import { FC, PropsWithChildren } from "react";

import { EntityLayout } from "@/components/EntityLayout";

import { ModelEntityNodes } from "./ModelEntityNodes";

type Props = {
type Props = PropsWithChildren<{
username: string;
slug: string;
};
}>;

export const FallbackModelLayout: FC<Props> = ({ username, slug }) => {
export const FallbackModelLayout: FC<Props> = ({
username,
slug,
children,
}) => {
return (
<EntityLayout
// Note that we don't pass `__typename` here.
Expand All @@ -25,6 +29,8 @@ export const FallbackModelLayout: FC<Props> = ({ username, slug }) => {
}}
/>
}
/>
>
{children}
</EntityLayout>
);
};
8 changes: 7 additions & 1 deletion packages/hub/src/app/models/[owner]/[slug]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ async function LoadedLayout({ params, children }: Props) {
export default async function Layout({ params, children }: Props) {
const { owner, slug } = await params;
return (
<Suspense fallback={<FallbackModelLayout username={owner} slug={slug} />}>
<Suspense
fallback={
<FallbackModelLayout username={owner} slug={slug}>
{children}
</FallbackModelLayout>
}
>
<LoadedLayout params={params}>{children}</LoadedLayout>
</Suspense>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/hub/src/squiggle/components/ImportTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const ImportTooltip: FC<Props> = ({ importId }) => {
// TODO - this is done with a server action, so it's not cached.
// A route would be better.
loadModelCardAction({ owner, slug }).then(setModel);
}, []);
}, [owner, slug]);

return (
<div
Expand Down

0 comments on commit 265fcec

Please sign in to comment.