From 49da3e393573c46a3f59ddeb4e69c832d0f0871f Mon Sep 17 00:00:00 2001 From: circle-gon <14517910-circle-gon@users.noreply.gitlab.com> Date: Thu, 20 Feb 2025 13:11:53 -0500 Subject: [PATCH 1/5] refactor comments --- src/components/Comment.svelte | 204 +++++++++++++----- src/components/CommentList.svelte | 55 +++-- src/components/GameComments.svelte | 112 +++++++--- src/components/GameDiscussion.svelte | 37 +--- src/components/GameEditor.svelte | 13 -- src/components/GameEditor/ForumLink.svelte | 61 ------ src/components/admin/modals/Comment.svelte | 25 --- .../admin/panels/CommentFeed.svelte | 5 - .../admin/panels/Housekeeping.svelte | 58 +---- src/components/forum/ThreadReader.svelte | 8 - src/helper/fetchComments.ts | 58 ++++- src/helper/forum.ts | 51 +---- src/models/categoryrequest.ts | 24 --- src/models/comment.ts | 35 ++- src/models/forumcategory.ts | 4 - src/models/forumpost.ts | 4 - src/models/forumthread.ts | 4 - src/pages/api/admin/edit/comment.ts | 8 +- src/pages/api/admin/grantCategory.ts | 42 ---- src/pages/api/admin/housekeepingData.ts | 4 +- src/pages/api/admin/nopeCategory.ts | 17 -- src/pages/api/comments/delete.ts | 5 +- src/pages/api/comments/edit.ts | 76 +++++++ src/pages/api/comments/fetch.ts | 49 +++++ src/pages/api/comments/new.ts | 48 ++++- src/pages/api/comments/reply.ts | 59 ----- src/pages/api/forum/linkGame.ts | 37 ---- src/pages/api/forum/request.ts | 66 ------ src/pages/api/users/signup.ts | 4 +- src/pages/comments/[gameId].astro | 50 ++++- src/pages/edit/[editId].astro | 22 -- src/pages/forum/request.astro | 63 ------ src/pages/forum/thread/[threadId].astro | 6 - src/pages/play/[gameId].astro | 46 ---- src/pages/rewind/developer.astro | 4 - src/types.d.ts | 28 +-- 36 files changed, 588 insertions(+), 804 deletions(-) delete mode 100644 src/components/GameEditor/ForumLink.svelte delete mode 100644 src/models/categoryrequest.ts delete mode 100644 src/pages/api/admin/grantCategory.ts delete mode 100644 src/pages/api/admin/nopeCategory.ts create mode 100644 src/pages/api/comments/edit.ts create mode 100644 src/pages/api/comments/fetch.ts delete mode 100644 src/pages/api/comments/reply.ts delete mode 100644 src/pages/api/forum/linkGame.ts delete mode 100644 src/pages/api/forum/request.ts delete mode 100644 src/pages/forum/request.astro diff --git a/src/components/Comment.svelte b/src/components/Comment.svelte index 97c1592a..5457e1a2 100644 --- a/src/components/Comment.svelte +++ b/src/components/Comment.svelte @@ -13,14 +13,20 @@ id: number; } - export interface ReplyDetail { + export interface EditDetail { id: number; content: string; + rating: number; + } + + export interface ShowDetail { + id: number; }
@@ -140,6 +201,15 @@ before="•" style="date" /> + + {#if comment.type === "review"} + + {#each Array(comment.rating).fill(undefined) as _}{/each}{#each Array(5 - comment.rating).fill(undefined) as _}{/each} + {/if}
+ + {#if comment.author === userId} + {/if} {#if comment.author !== userId}
+ {:else if editing} + - - {/if} - {:else if data.devResponse !== undefined} -
{data.devResponse}
- {:else} - no dev response -
- {/if} -
votes
{data.upCount} diff --git a/src/components/admin/panels/CommentFeed.svelte b/src/components/admin/panels/CommentFeed.svelte index cac61148..47fc5c9d 100644 --- a/src/components/admin/panels/CommentFeed.svelte +++ b/src/components/admin/panels/CommentFeed.svelte @@ -87,11 +87,6 @@ if (str.length > 40) str = str.substring(0, 37) + "..."; return str; })(), - response: (() => { - let str = String(x.devResponse ?? ""); - if (str.length > 40) str = str.substring(0, 37) + "..."; - return str; - })(), deleted: x.deleted === true ? "yes" : "", }))} schema={{ diff --git a/src/components/admin/panels/Housekeeping.svelte b/src/components/admin/panels/Housekeeping.svelte index 1aee7da5..7cc074ac 100644 --- a/src/components/admin/panels/Housekeeping.svelte +++ b/src/components/admin/panels/Housekeeping.svelte @@ -1,6 +1,6 @@ @@ -96,22 +56,6 @@ /> {/if} -

forum category requests

- {#each data.crequests as cat, i} -
- {cat.name} - slug: {cat.slug}
- desc: {cat.description}
- why? {cat.reason}
- with - the parent -
- -
- {:else} - 🎉 - {/each} - {#if comment.type === "review"} - - {#each Array(comment.rating).fill(undefined) as _}{/each}{#each Array(5 - comment.rating).fill(undefined) as _}{/each} + + + {#each Array(comment.rating).fill(undefined) as _}{/each}{#each Array(5 - comment.rating).fill(undefined) as _}{/each} + {/if}
{#if comment.author === userId} + {#if comment.isOld && !isDev} + + {/if} {/if} {#if comment.author !== userId} @@ -299,11 +336,13 @@ {userId} {isLoggedIn} {isStaff} + {isDev} on:vote on:delete on:reveal on:edit on:show + on:convert bind:this={commentList} /> {#if isLimited} diff --git a/src/components/CommentList.svelte b/src/components/CommentList.svelte index c0432003..60c71636 100644 --- a/src/components/CommentList.svelte +++ b/src/components/CommentList.svelte @@ -1,5 +1,6 @@ {#each comments as comment, count (comment.id)} @@ -81,11 +95,13 @@ {isStaff} {loadDepth} {sort} + {isDev} on:vote on:delete on:reveal on:edit on:show + on:convert bind:this={comps[count]} /> {/each} diff --git a/src/components/GameComments.svelte b/src/components/GameComments.svelte index 9a1de084..e7f6b58d 100644 --- a/src/components/GameComments.svelte +++ b/src/components/GameComments.svelte @@ -1,5 +1,6 @@
@@ -235,13 +235,21 @@ /> {#if comment.type === "review"} - + {#each Array(comment.rating).fill(undefined) as _}{/each}{#each Array(5 - comment.rating).fill(undefined) as _}{/each} + icon="material-symbols:star-rounded" + width="16" + inline + />{/each}{#each Array(5 - comment.rating).fill(undefined) as _}{/each} {/if}
@@ -271,12 +279,18 @@ {#if isLoggedIn && !comment.deleted} - + {#if comment.author === userId} {#if comment.isOld && !isDev} - + {/if} - + {/if} {#if comment.author !== userId} @@ -241,7 +243,7 @@ outline: 1px solid #7770; border-radius: 3px; } - + #compose-comment :global(.markdown-editor) { margin-top: 12px; } diff --git a/src/helper/fetchComments.ts b/src/helper/fetchComments.ts index 32c3ac9c..1ae8272e 100644 --- a/src/helper/fetchComments.ts +++ b/src/helper/fetchComments.ts @@ -48,36 +48,39 @@ export async function idToComments( filter: "all" | "comment" | "review", parent: number, sortDev: boolean, - userId?: number, + userId?: number ) { // Wow I don't like that const looky = { game: gameId, parent, deleted: false, - } - if (filter !== "all") (looky as any).type = filter + }; + if (filter !== "all") (looky as any).type = filter; - let comments: IComment[] = [] + let comments: IComment[] = []; if (sortDev) { // TODO there is probably a better way for this - const devId = (await Game.findOne({ id: gameId })).author + const devId = (await Game.findOne({ id: gameId })).author; comments = await Comment.find({ ...looky, - author: devId + author: devId, }) .sort({ [sort]: -1 }) .limit(5); if (comments.length < 5) { - comments.push(...await Comment.find({ - ...looky, - author: { - $not: { - $eq: devId - } - } - }).sort({ [sort]: -1 }) - .limit(5 - comments.length)) + comments.push( + ...(await Comment.find({ + ...looky, + author: { + $not: { + $eq: devId, + }, + }, + }) + .sort({ [sort]: -1 }) + .limit(5 - comments.length)) + ); } } else { comments = await Comment.find(looky) @@ -128,7 +131,7 @@ export async function paginateComments( userId?: number ) { const paginated = await Comment.paginate( - { game: gameId, deleted: false, parent}, + { game: gameId, deleted: false, parent }, { sort: "-" + sort, page, limit: 20 } ); diff --git a/src/pages/api/comments/convert.ts b/src/pages/api/comments/convert.ts index e21cb9bb..bac7193c 100644 --- a/src/pages/api/comments/convert.ts +++ b/src/pages/api/comments/convert.ts @@ -18,7 +18,7 @@ export const POST = route( auth: true, notMuted: true, notUnderage: true, - schema + schema, }, async ({ locals }, { id: commentId }) => { const { user } = locals.auth; @@ -27,35 +27,47 @@ export const POST = route( id: commentId, deleted: false, }); - + // No check for parent / comment because isOld should only be applied to non-reply comments if (!comment) return rmsg("Comment does not exist", 404); - if (comment.author !== user.id) return rmsg("You are not the author of this comment", 403) - if (!comment.isOld) return rmsg("This comment cannot be converted", 403) + if (comment.author !== user.id) + return rmsg("You are not the author of this comment", 403); + if (!comment.isOld) + return rmsg("This comment cannot be converted", 403); const game = await Game.findOne({ - id: comment.game - }) - if (game.author === user.id) return rmsg("You can't submit a review on your own game", 403) + id: comment.game, + }); + if (game.author === user.id) + return rmsg("You can't submit a review on your own game", 403); - const has = await Comment.findOne({ author: user.id, game: game.id, type: "review", deleted: false }) - if (has) return rmsg("Only one review is allowed", 403) - - const rate = await Rating.findOne({ author: user.id, game: game.id }) - if (!rate) return rmsg("A game rating is required for a review", 403) + const has = await Comment.findOne({ + author: user.id, + game: game.id, + type: "review", + deleted: false, + }); + if (has) return rmsg("Only one review is allowed", 403); + + const rate = await Rating.findOne({ author: user.id, game: game.id }); + if (!rate) return rmsg("A game rating is required for a review", 403); // Need to check length here - if (comment.content.length < 10) return rmsg("Minimum review length is 10 characters", 403) - const rating = rate.rating - - comment.isOld = false - comment.type = "review" - comment.rating = rating - await comment.save() - - return rdata({ - msg: "success", - rating - }, 200); + if (comment.content.length < 10) + return rmsg("Minimum review length is 10 characters", 403); + const rating = rate.rating; + + comment.isOld = false; + comment.type = "review"; + comment.rating = rating; + await comment.save(); + + return rdata( + { + msg: "success", + rating, + }, + 200 + ); } ); diff --git a/src/pages/api/comments/edit.ts b/src/pages/api/comments/edit.ts index fd0ce448..c6b9c016 100644 --- a/src/pages/api/comments/edit.ts +++ b/src/pages/api/comments/edit.ts @@ -25,33 +25,45 @@ export const POST = route( auth: true, notMuted: true, notUnderage: true, - schema + schema, }, async ({ locals }, { id: commentId, content }) => { const { user } = locals.auth; - const comment = await Comment.findOne({ id: commentId, deleted: false }) - if (!comment) return rmsg("Comment not found", 404) - if (comment.author !== user.id) return rmsg("You are not the author of this comment", 403) + const comment = await Comment.findOne({ + id: commentId, + deleted: false, + }); + if (!comment) return rmsg("Comment not found", 404); + if (comment.author !== user.id) + return rmsg("You are not the author of this comment", 403); - const prevContent = comment.content - let rating = -1 + const prevContent = comment.content; + let rating = -1; if (comment.type === "review") { - const rate = await Rating.findOne({ author: user.id, game: comment.game }) - if (!rate) return rmsg("A game rating is required for a review", 403) - rating = rate.rating + const rate = await Rating.findOne({ + author: user.id, + game: comment.game, + }); + if (!rate) + return rmsg("A game rating is required for a review", 403); + rating = rate.rating; } // Need to check length here - const reqLength = comment.type === "review" ? 10 : 3 - if (content.length < reqLength) return rmsg(`Minimum ${comment.type} length is ${reqLength} characters`, 403) + const reqLength = comment.type === "review" ? 10 : 3; + if (content.length < reqLength) + return rmsg( + `Minimum ${comment.type} length is ${reqLength} characters`, + 403 + ); - comment.content = content - comment.rating = rating + comment.content = content; + comment.rating = rating; await comment.save(); // this should always be non-null right - const game = await Game.findOne({ id: comment.game }) + const game = await Game.findOne({ id: comment.game }); if (env.STAFF_COMMENT_WEBHOOK !== undefined && game !== null) await sendFancyWebhook(env.STAFF_COMMENT_WEBHOOK, { embeds: [ @@ -81,7 +93,7 @@ currently: return rdata( { message: "success", - rating + rating, }, 201 ); diff --git a/src/pages/api/comments/fetch.ts b/src/pages/api/comments/fetch.ts index ec405f58..ee43f50b 100644 --- a/src/pages/api/comments/fetch.ts +++ b/src/pages/api/comments/fetch.ts @@ -9,41 +9,52 @@ const schema = z.object({ sort: z.union([z.literal("createdAt"), z.literal("score")]), game: z.number().int().min(1), id: z.number().int(), - filter: z.union([z.literal("all"), z.literal("comment"), z.literal("review")]) -}) - + filter: z.union([ + z.literal("all"), + z.literal("comment"), + z.literal("review"), + ]), +}); + // This probably does not need to be POST export const POST = route( { - schema + schema, }, async ({ locals }, { game, id, sort, filter }) => { - const gameDB = await Game.findOne({ id: game }) - if (!gameDB) return rmsg("Game does not exist", 404) + const gameDB = await Game.findOne({ id: game }); + if (!gameDB) return rmsg("Game does not exist", 404); if (id !== -1) { - const comment = await Comment.findOne({ id, deleted: false }) - if (!comment) return rmsg("Comment not found", 404) + const comment = await Comment.findOne({ id, deleted: false }); + if (!comment) return rmsg("Comment not found", 404); } - const userId = locals.auth.user?.id - const isLimited = (await Comment.countDocuments({ - game, - parent: id, - deleted: false, - })) > 5 + const userId = locals.auth.user?.id; + const isLimited = + (await Comment.countDocuments({ + game, + parent: id, + deleted: false, + })) > 5; // Double await seems cursed - const result = (await attachNamesToComments(await idToComments(game, sort, filter, id, id !== -1, userId))) - .map(i => ({ - ...i, - // Date does not work here :( - createdAt: +i.createdAt - })) - return rdata({ - message: "success", - result, - isLimited - }, 200) + const result = ( + await attachNamesToComments( + await idToComments(game, sort, filter, id, id !== -1, userId) + ) + ).map(i => ({ + ...i, + // Date does not work here :( + createdAt: +i.createdAt, + })); + return rdata( + { + message: "success", + result, + isLimited, + }, + 200 + ); } ); diff --git a/src/pages/api/comments/new.ts b/src/pages/api/comments/new.ts index 09e3f71c..83c0d8a0 100644 --- a/src/pages/api/comments/new.ts +++ b/src/pages/api/comments/new.ts @@ -10,21 +10,27 @@ import { keyv } from "~/models/keyv"; import { sendFancyWebhook } from "~/helper/sendWebhook"; import { z } from "zod"; -const schema = z.object({ game: z.number().min(1).int(), parent: z.number().int() }).and( - z.object({ - type: z.literal("comment"), - content: z - .string() - .min(3, "Minimum comment length is 3 characters") - .max(4096), - }).or(z.object({ - type: z.literal("review"), - content: z - .string() - .min(10, "Minimum review length is 10 characters") - .max(4096) - })) -) +const schema = z + .object({ game: z.number().min(1).int(), parent: z.number().int() }) + .and( + z + .object({ + type: z.literal("comment"), + content: z + .string() + .min(3, "Minimum comment length is 3 characters") + .max(4096), + }) + .or( + z.object({ + type: z.literal("review"), + content: z + .string() + .min(10, "Minimum review length is 10 characters") + .max(4096), + }) + ) + ); export const POST = route( { @@ -48,24 +54,33 @@ export const POST = route( const author = user.id; const lastCommentId = await keyv.id("lastCommentId"); - let rating = -1 + let rating = -1; if (type === "review") { - if (parent !== -1) return rmsg("You can't reply with a review", 403) - if (game.author === user.id) return rmsg("You can't submit a review on your own game", 403) - - const has = await Comment.findOne({ author, game: gameId, type, deleted: false }) - if (has) return rmsg("Only one review is allowed", 403) + if (parent !== -1) + return rmsg("You can't reply with a review", 403); + if (game.author === user.id) + return rmsg("You can't submit a review on your own game", 403); + + const has = await Comment.findOne({ + author, + game: gameId, + type, + deleted: false, + }); + if (has) return rmsg("Only one review is allowed", 403); - const rate = await Rating.findOne({ author, game: gameId }) - if (!rate) return rmsg("A game rating is required for a review", 403) - rating = rate.rating + const rate = await Rating.findOne({ author, game: gameId }); + if (!rate) + return rmsg("A game rating is required for a review", 403); + rating = rate.rating; } - let parentComment = undefined + let parentComment = undefined; if (parent !== -1) { - parentComment = await Comment.findOne({ id: parent }) - if (!parentComment) return rmsg("Can't reply to a nonexistent comment", 404) + parentComment = await Comment.findOne({ id: parent }); + if (!parentComment) + return rmsg("Can't reply to a nonexistent comment", 404); } // TODO limit comments per user per game (10?) @@ -81,7 +96,7 @@ export const POST = route( upCount: 1, down: [], score: 1, - isOld: false + isOld: false, }); game.comments++; @@ -100,9 +115,9 @@ Your comment: > ${parentComment.content} ${user.name}'${user.name.endsWith("s") ? "" : "s"} reply: -> ${content}` - }) - await message.save() +> ${content}`, + }); + await message.save(); } if (env.STAFF_COMMENT_WEBHOOK !== undefined) diff --git a/src/pages/api/users/signup.ts b/src/pages/api/users/signup.ts index e11e0f79..5013f9d9 100644 --- a/src/pages/api/users/signup.ts +++ b/src/pages/api/users/signup.ts @@ -27,7 +27,7 @@ export const POST = route( ), schema, }, - async ({ request, cookies }, req) => { + async ({ request, clientAddress, cookies }, req) => { cookies.set("birth-info", req.year + "," + req.month, { maxAge: 60 * 60 * 24 * 365 * 2, path: "/", @@ -38,7 +38,7 @@ export const POST = route( formData.append("response", req.captcha); formData.append( "remoteip", - request.headers.get("CF-Connecting-IP") + request.headers.get("CF-Connecting-IP") ?? clientAddress ); const url = "https://challenges.cloudflare.com/turnstile/v0/siteverify"; diff --git a/src/pages/comments/[gameId].astro b/src/pages/comments/[gameId].astro index de9c4543..dac5ee74 100644 --- a/src/pages/comments/[gameId].astro +++ b/src/pages/comments/[gameId].astro @@ -1,6 +1,10 @@ --- -import { attachNamesToComments, frontendifyComments, paginateComments } from "~/helper/fetchComments"; -import Comment from "~/components/Comment.svelte" +import { + attachNamesToComments, + frontendifyComments, + paginateComments, +} from "~/helper/fetchComments"; +import Comment from "~/components/Comment.svelte"; import CommentList from "~/components/CommentList.svelte"; import { Comment as CommentModel } from "~/models/comment"; import { Game } from "~/models/game"; @@ -24,8 +28,8 @@ if (sortRaw === "time") sort = "createdAt"; else if (sortRaw === "top") sort = "score"; // Ignore invalid sorts -let parent = parseInt(Astro.url.searchParams.get("parent")) -if (isNaN(parent)) parent = -1 +let parent = parseInt(Astro.url.searchParams.get("parent")); +if (isNaN(parent)) parent = -1; const { user, loggedIn, needsVerification } = Astro.locals.auth; @@ -35,16 +39,19 @@ if (isNaN(gameNum)) return new Response(null, { status: 404 }); const game = await Game.findOne({ id: gameId }); if (!game) return new Response(null, { status: 404 }); -let thisComment = undefined -let nextParent = "" +let thisComment = undefined; +let nextParent = ""; if (parent !== -1) { - const comment = await CommentModel.findOne({ id: parent }) - if (!comment) return new Response(null, { status: 404 }) - thisComment = (await attachNamesToComments(frontendifyComments([comment], user?.id)))[0] - if (thisComment.parent !== undefined) nextParent = `&parent=${thisComment.parent}` + const comment = await CommentModel.findOne({ id: parent }); + if (!comment) return new Response(null, { status: 404 }); + thisComment = ( + await attachNamesToComments(frontendifyComments([comment], user?.id)) + )[0]; + if (thisComment.parent !== undefined) + nextParent = `&parent=${thisComment.parent}`; } -const isDev = user?.id === game.author +const isDev = user?.id === game.author; const { comments, pages } = await paginateComments( gameNum, @@ -75,23 +82,34 @@ if (import.meta.env.PROD) { - {parent !== undefined ? go up : null} + { + parent !== undefined ? ( + + go up + + ) : null + } go back

- {parent !== undefined ? ( - - ) : null} + { + parent !== undefined ? ( + + ) : null + }
Date: Thu, 20 Feb 2025 13:11:55 -0500 Subject: [PATCH 4/5] touchup (i forgot the reply dispatcher) --- src/components/Comment.svelte | 31 ++++++++++++------- src/components/CommentList.svelte | 18 +++++++++++ src/components/GameComments.svelte | 9 ++++++ .../admin/panels/CommentFeed.svelte | 1 - src/helper/fetchComments.ts | 1 + src/pages/api/comments/new.ts | 1 + src/pages/comments/[gameId].astro | 5 ++- src/types.d.ts | 2 ++ 8 files changed, 53 insertions(+), 15 deletions(-) diff --git a/src/components/Comment.svelte b/src/components/Comment.svelte index 188cce34..999594e6 100644 --- a/src/components/Comment.svelte +++ b/src/components/Comment.svelte @@ -27,6 +27,11 @@ id: number; rating: number; } + + export interface ReplyDetail { + id: number; + comment: INamedFrontendComment; + } {#each comments as comment, count (comment.id)} @@ -108,6 +125,7 @@ on:edit on:show on:convert + on:reply bind:this={comps[count]} /> {/each} diff --git a/src/components/GameComments.svelte b/src/components/GameComments.svelte index 9df5e7b3..38d874a4 100644 --- a/src/components/GameComments.svelte +++ b/src/components/GameComments.svelte @@ -3,6 +3,7 @@ ConvertDetail, DeleteDetail, EditDetail, + ReplyDetail, RevealDetail, ShowDetail, VoteDetail, @@ -87,6 +88,11 @@ topCommentDiv?.doConvert(detail); } + function handleReply({ detail }: CustomEvent) { + newCommentDiv.doReply(detail); + topCommentDiv?.doReply(detail); + } + async function getComments(filter: "all" | "comment" | "review") { loaded = false; @@ -168,6 +174,7 @@ on:edit={handleEdit} on:show={handleShow} on:convert={handleConvert} + on:reply={handleReply} bind:this={newCommentDiv} />
@@ -190,6 +197,7 @@ on:edit={handleEdit} on:show={handleShow} on:convert={handleConvert} + on:reply={handleReply} bind:this={newCommentDiv} />
@@ -211,6 +219,7 @@ on:edit={handleEdit} on:show={handleShow} on:convert={handleConvert} + on:reply={handleReply} bind:this={topCommentDiv} />
diff --git a/src/components/admin/panels/CommentFeed.svelte b/src/components/admin/panels/CommentFeed.svelte index 47fc5c9d..137c7aa5 100644 --- a/src/components/admin/panels/CommentFeed.svelte +++ b/src/components/admin/panels/CommentFeed.svelte @@ -96,7 +96,6 @@ score: { name: "score", type: "score" }, deleted: { name: "deleted" }, content: { name: "content" }, - response: { name: "developer response" }, }} onitemclick={x => { const comment = data.find(y => y.id == x.id); diff --git a/src/helper/fetchComments.ts b/src/helper/fetchComments.ts index 1ae8272e..eda2994c 100644 --- a/src/helper/fetchComments.ts +++ b/src/helper/fetchComments.ts @@ -22,6 +22,7 @@ export function frontendifyComments( content: c.content, score: c.score, showMore: false, + isLimited: false, // TODO: magic number :( hidden: c.score <= -5, deleted: c.deleted, diff --git a/src/pages/api/comments/new.ts b/src/pages/api/comments/new.ts index 83c0d8a0..6a890a9e 100644 --- a/src/pages/api/comments/new.ts +++ b/src/pages/api/comments/new.ts @@ -152,6 +152,7 @@ ${user.name}'${user.name.endsWith("s") ? "" : "s"} reply: score: 1, hidden: false, deleted: false, + isLimited: false, createdAt: +comment.createdAt, yourVote: 1, type, diff --git a/src/pages/comments/[gameId].astro b/src/pages/comments/[gameId].astro index dac5ee74..58913504 100644 --- a/src/pages/comments/[gameId].astro +++ b/src/pages/comments/[gameId].astro @@ -47,8 +47,7 @@ if (parent !== -1) { thisComment = ( await attachNamesToComments(frontendifyComments([comment], user?.id)) )[0]; - if (thisComment.parent !== undefined) - nextParent = `&parent=${thisComment.parent}`; + if (thisComment.parent !== -1) nextParent = `&parent=${thisComment.parent}`; } const isDev = user?.id === game.author; @@ -83,7 +82,7 @@ if (import.meta.env.PROD) { { - parent !== undefined ? ( + parent !== -1 ? ( Date: Thu, 20 Feb 2025 14:22:33 -0500 Subject: [PATCH 5/5] alignment touchup and comment page fix --- src/components/Comment.svelte | 3 ++- src/components/Header.astro | 1 + src/pages/comments/[gameId].astro | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/Comment.svelte b/src/components/Comment.svelte index 999594e6..354c6c65 100644 --- a/src/components/Comment.svelte +++ b/src/components/Comment.svelte @@ -391,7 +391,8 @@