- {/* These links do not preserve current URL queries. E.g. if ?page=2, that'll be removed once one of these links is clicked */}
-
-
-
-
- );
-}
-
function SetupInstruction() {
return (
@@ -80,68 +40,17 @@ function SetupInstruction() {
);
}
+// deno-lint-ignore require-await
export default async function HomePage(
_req: Request,
ctx: RouteContext
,
) {
- const pageNum = calcPageNum(ctx.url);
- const timeAgo = calcTimeAgoFilter(ctx.url);
- let allItems: Item[];
- if (timeAgo === "week" || timeAgo === null) {
- allItems = await getItemsSince(WEEK);
- } else if (timeAgo === "month") {
- allItems = await getItemsSince(30 * DAY);
- } else {
- allItems = await getAllItems();
- }
-
- const items = allItems
- .toSorted(compareScore)
- .slice((pageNum - 1) * PAGE_LENGTH, pageNum * PAGE_LENGTH);
-
- const areVoted = await getAreVotedBySessionId(
- items,
- ctx.state.sessionId,
- );
- const lastPage = calcLastPage(allItems.length, PAGE_LENGTH);
-
return (
<>
{NEEDS_SETUP && }
-
- {items.length === 0 && (
- <>
-
- >
- )}
-
- {items.map((item, index) => (
-
- ))}
- {lastPage > 1 && (
-
- )}
+
>
);
diff --git a/routes/users/[login].tsx b/routes/users/[login].tsx
index 8cebc0a47..4600315fe 100644
--- a/routes/users/[login].tsx
+++ b/routes/users/[login].tsx
@@ -1,23 +1,15 @@
// Copyright 2023 the Deno authors. All rights reserved. MIT license.
import type { RouteContext } from "$fresh/server.ts";
import type { State } from "@/routes/_middleware.ts";
-import ItemSummary from "@/components/ItemSummary.tsx";
-import { calcLastPage, calcPageNum, PAGE_LENGTH } from "@/utils/pagination.ts";
-import PageSelector from "@/components/PageSelector.tsx";
-import {
- compareScore,
- getAreVotedBySessionId,
- getItemsByUser,
- getUser,
-} from "@/utils/db.ts";
-import { pluralize } from "@/utils/display.ts";
+import { getUser } from "@/utils/db.ts";
import IconBrandGithub from "tabler_icons_tsx/brand-github.tsx";
import { LINK_STYLES } from "@/utils/constants.ts";
import Head from "@/components/Head.tsx";
import GitHubAvatarImg from "@/components/GitHubAvatarImg.tsx";
+import ItemsList from "@/islands/ItemsList.tsx";
function Profile(
- props: { login: string; itemsCount: number; isSubscribed: boolean },
+ props: { login: string; isSubscribed: boolean },
) {
return (
@@ -41,9 +33,6 @@ function Profile(
-
- {pluralize(props.itemsCount, "submission")}
-
);
@@ -57,23 +46,6 @@ export default async function UsersUserPage(
const user = await getUser(login);
if (user === null) return await ctx.renderNotFound();
- const pageNum = calcPageNum(ctx.url);
-
- const allItems = await getItemsByUser(login);
- const itemsCount = allItems.length;
-
- const items = allItems.sort(compareScore).slice(
- (pageNum - 1) * PAGE_LENGTH,
- pageNum * PAGE_LENGTH,
- );
-
- const areVoted = await getAreVotedBySessionId(
- items,
- ctx.state.sessionId,
- );
-
- const lastPage = calcLastPage(allItems.length, PAGE_LENGTH);
-
return (
<>