Connect, collaborate, and grow with a community of TypeScript developers
feat: Updates some code filtering (#302)
Jim Burbridge6c4208cd1fe5
diff --git a/prisma/schema.prisma b/prisma/schema.prismaindex bdc8d2af..f7e80743 100644--- a/prisma/schema.prisma+++ b/prisma/schema.prisma@@ -299,6 +299,7 @@ enum CommentRoot {model Comment {id Int @id @default(autoincrement())text String @db.MediumText+ visible Boolean @default(true)parentId Int?userId Stringdiff --git a/src/app/challenge/[id]/getChallengeRouteData.ts b/src/app/challenge/[id]/getChallengeRouteData.tsindex 690d6f5a..546bd3d0 100644--- a/src/app/challenge/[id]/getChallengeRouteData.ts+++ b/src/app/challenge/[id]/getChallengeRouteData.ts@@ -10,12 +10,7 @@ export const getChallengeRouteData = cache((id: string, session: Session | null)return prisma.challenge.findFirstOrThrow({where: {id: +id,- status: 'ACTIVE',- user: {- NOT: {- status: 'BANNED',- },- },+ status: 'ACTIVE'},include: {user: true,@@ -36,6 +31,7 @@ export const getChallengeRouteData = cache((id: string, session: Session | null)where: {rootType: 'CHALLENGE',rootChallengeId: +id,+ visible: true,},include: {user: true,diff --git a/src/components/admin/admin.actions.tsx b/src/components/admin/admin.actions.tsxindex c5dedfab..42130881 100644--- a/src/components/admin/admin.actions.tsx+++ b/src/components/admin/admin.actions.tsx@@ -185,6 +185,14 @@ export async function banUser(userId: string, reportId: number, banReason?: striupdatedAt: new Date(),},}),+ prisma.comment.updateMany({+ where: {+ userId: userId,+ },+ data: {+ visible: false,+ }+ })]);}/**diff --git a/src/components/challenge/comments/getCommentRouteData.ts b/src/components/challenge/comments/getCommentRouteData.tsindex 08817e65..4d6ab271 100644--- a/src/components/challenge/comments/getCommentRouteData.ts+++ b/src/components/challenge/comments/getCommentRouteData.ts@@ -14,6 +14,7 @@ export async function getInfiniteComments({ challengeId, lastCursor }: QueryParawhere: {rootType: 'CHALLENGE',rootChallengeId: challengeId,+ visible: true,},...(lastCursor && {skip: 1,