diff --git a/apps/cyberstorm-remix/app/c/community.tsx b/apps/cyberstorm-remix/app/c/community.tsx index 455a18746..a3bca9946 100644 --- a/apps/cyberstorm-remix/app/c/community.tsx +++ b/apps/cyberstorm-remix/app/c/community.tsx @@ -1,5 +1,10 @@ -import type { LoaderFunctionArgs, MetaFunction } from "react-router"; -import { useLoaderData, useOutletContext } from "react-router"; +import type { LoaderFunctionArgs } from "react-router"; +import { + Await, + useLoaderData, + useLocation, + useOutletContext, +} from "react-router"; import { NewBreadCrumbs, NewBreadCrumbsLink, @@ -20,47 +25,7 @@ import { getPublicEnvVariables, getSessionTools, } from "cyberstorm/security/publicEnvVariables"; - -export const meta: MetaFunction = ({ data, location }) => { - return [ - { title: `Thunderstore - The ${data?.community.name} Mod Database` }, - { name: "description", content: `Mods for ${data?.community.name}` }, - { - property: "og:type", - content: "website", - }, - { - property: "og:url", - content: `${import.meta.env.VITE_SITE_URL}${location.pathname}`, - }, - { - property: "og:title", - content: `Thunderstore - The ${data?.community.name} Mod Database`, - }, - { - property: "og:description", - content: data - ? `Thunderstore is a mod database and API for downloading ${data.community.name} mods` - : undefined, - }, - { - property: "og:image:width", - content: "360", - }, - { - property: "og:image:height", - content: "480", - }, - { - property: "og:image", - content: data?.community.cover_image_url, - }, - { - property: "og:site_name", - content: "Thunderstore", - }, - ]; -}; +import { Suspense } from "react"; export async function loader({ request, params }: LoaderFunctionArgs) { if (params.communityId) { @@ -81,7 +46,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) { const section = searchParams.get("section"); const nsfw = searchParams.get("nsfw"); const deprecated = searchParams.get("deprecated"); - const community = await dapper.getCommunity(params.communityId); + const community = dapper.getCommunity(params.communityId); const filters = await dapper.getCommunityFilters(params.communityId); const sortedSections = filters.sections.sort( (a, b) => b.priority - a.priority @@ -89,7 +54,7 @@ export async function loader({ request, params }: LoaderFunctionArgs) { return { community: community, filters: filters, - listings: await dapper.getPackageListings( + listings: dapper.getPackageListings( { kind: "community", communityId: params.communityId, @@ -134,7 +99,7 @@ export async function clientLoader({ request, params }: LoaderFunctionArgs) { const section = searchParams.get("section"); const nsfw = searchParams.get("nsfw"); const deprecated = searchParams.get("deprecated"); - const community = await dapper.getCommunity(params.communityId); + const community = dapper.getCommunity(params.communityId); const filters = await dapper.getCommunityFilters(params.communityId); const sortedSections = filters.sections.sort( (a, b) => b.priority - a.priority @@ -142,7 +107,7 @@ export async function clientLoader({ request, params }: LoaderFunctionArgs) { return { community: community, filters: filters, - listings: await dapper.getPackageListings( + listings: dapper.getPackageListings( { kind: "community", communityId: params.communityId, @@ -174,19 +139,68 @@ export default function Community() { >(); const outletContext = useOutletContext() as OutletContextShape; + const location = useLocation(); return ( <> -
- {community.hero_image_url ? ( - {community.name} - ) : null} -
-
+ + + {(resolvedValue) => { + return ( + <> + + + + + + + + + + + + ); + }} + + + + + + {(resolvedValue) => { + return resolvedValue.hero_image_url ? ( + <> +
+ {resolvedValue.name} +
+
+ + ) : null; + }} + +
- {community.name} + + Loading}> + }> + {(resolvedValue) => { + return <>{resolvedValue.name}; + }} + + + - - {community.wiki_url ? ( - - - - - Modding Wiki - - - - - ) : null} - {community.discord_url ? ( - Loading}> + }> + {(resolvedValue) => { + return ( + + {resolvedValue.wiki_url ? ( + + + + + Modding Wiki + + + + + ) : null} + {resolvedValue.discord_url ? ( + + + + + Modding Discord + + + + + ) : null} + + } > - - - - Modding Discord - - - - - ) : null} - - } - > - {community.name} - + {resolvedValue.name} + + ); + }} + + + ; packageCategories: PackageCategory[]; sections: Section[]; config: () => RequestConfig; @@ -154,8 +150,6 @@ export function PackageSearch(props: Props) { dapper, } = props; - const navigation = useNavigation(); - const navigationType = useNavigationType(); const [searchParams, setSearchParams] = useSearchParams(); @@ -589,12 +583,20 @@ export function PackageSearch(props: Props) { />
- + Loading...}> + }> + {(resolvedValue) => { + return ( + + ); + }} + +
{/*
*/} @@ -607,72 +609,93 @@ export function PackageSearch(props: Props) {
- - {listings.results.length > 0 ? ( -
- {listings.results.map((p) => ( - { - if (likeAction) { - likeAction( - ratedPackages.includes(`${p.namespace}-${p.name}`), - p.namespace, - p.name, - Boolean(currentUser?.username) - ); - } - }} - /> - ))} -
- ) : (searchParamsBlob.order !== undefined && searchParams.size > 1) || - (searchParamsBlob.order === undefined && searchParams.size > 0) ? ( - - - - -
- No results found - - Make sure all keywords are spelled correctly or try different - search parameters. - -
- resetParams(searchParamsBlob.order)} - rootClasses="no-result__button" - > - Clear all filters - -
- ) : ( - - - - -
- It's empty in here - - Be the first to upload a mod! - -
-
- )} -
+ Loading...}> + }> + {(resolvedValue) => { + return ( +
+ {resolvedValue.results.length > 0 ? ( +
+ {resolvedValue.results.map((p) => ( + { + if (likeAction) { + likeAction( + ratedPackages.includes( + `${p.namespace}-${p.name}` + ), + p.namespace, + p.name, + Boolean(currentUser?.username) + ); + } + }} + /> + ))} +
+ ) : (searchParamsBlob.order !== undefined && + searchParams.size > 1) || + (searchParamsBlob.order === undefined && + searchParams.size > 0) ? ( + + + + +
+ No results found + + Make sure all keywords are spelled correctly or try + different search parameters. + +
+ resetParams(searchParamsBlob.order)} + rootClasses="no-result__button" + > + Clear all filters + +
+ ) : ( + + + + +
+ + It's empty in here + + + Be the first to upload a mod! + +
+
+ )} +
+ ); + }} +
+
- + Loading...}> + }> + {(resolvedValue) => { + return ( + + ); + }} + +
diff --git a/apps/cyberstorm-remix/app/commonComponents/PageHeader/PageHeader.css b/apps/cyberstorm-remix/app/commonComponents/PageHeader/PageHeader.css index 1836b0db0..0354737f7 100644 --- a/apps/cyberstorm-remix/app/commonComponents/PageHeader/PageHeader.css +++ b/apps/cyberstorm-remix/app/commonComponents/PageHeader/PageHeader.css @@ -1,7 +1,6 @@ @layer nimbus-components { .page-header { display: flex; - flex: 1 1 0; flex-direction: row; gap: var(--space-32); align-items: flex-start; diff --git a/apps/cyberstorm-remix/app/root.tsx b/apps/cyberstorm-remix/app/root.tsx index fe5535591..cde2bb418 100644 --- a/apps/cyberstorm-remix/app/root.tsx +++ b/apps/cyberstorm-remix/app/root.tsx @@ -12,7 +12,7 @@ import { useLoaderData, useLocation, useRouteError, - useRouteLoaderData, + // useRouteLoaderData, } from "react-router"; // import { LinksFunction } from "@remix-run/react/dist/routeModules"; import { Provider as RadixTooltip } from "@radix-ui/react-tooltip"; @@ -269,7 +269,7 @@ const TooltipProvider = memo(function TooltipProvider({ }); function App() { - const data = useRouteLoaderData("root"); + const data = useLoaderData(); const dapper = new DapperTs(() => { return { apiHost: data?.publicEnvVariables.ENV.VITE_API_URL,