Skip to content

Commit 95f53b6

Browse files
committed
Added a bot label
1 parent a160674 commit 95f53b6

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

app/(main)/threads/[id]/thread-client-page.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { avatars } from "@/lib/appwrite"
1414
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
1515
import { Button } from "@/components/ui/button"
1616
import { Clock, TrendingUp, Reply, ChevronDown, ChevronUp, Trash2 } from "lucide-react"
17+
import { BotLabel } from "@/components/bot-label"
1718

1819
interface ThreadClientPageProps {
1920
article: NewsItem
@@ -85,13 +86,18 @@ const CommentItem = memo<CommentItemProps>(({
8586
<div className="flex-1">
8687
<div className="flex items-center gap-2 text-xs mb-2">
8788
<span className="text-gray-800">{comment.author}</span>
89+
{/* Bot detection logic - show for falsy values (0, empty string, undefined) */}
90+
{!comment.userId || comment.userId === '0' && (
91+
<BotLabel />
92+
)}
8893
{isOriginalPoster(comment.userId || '') && (
8994
<>
9095
<span className="text-gray-500"></span>
9196
<span className="text-gray-500 text-xs">original poster</span>
9297
</>
9398
)}
94-
<span className="text-gray-500">{comment.timeAgo}</span>
99+
<span className="text-gray-500"></span>
100+
<span className="text-gray-500 text-xs">{comment.timeAgo}</span>
95101
</div>
96102
<div className="text-gray-700 text-sm mb-3 whitespace-pre-wrap">{comment.text}</div>
97103

components/bot-label.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React from "react"
2+
3+
interface BotLabelProps {
4+
className?: string
5+
}
6+
7+
export function BotLabel({ className }: BotLabelProps) {
8+
return (
9+
<>
10+
<span className="text-gray-500"></span>
11+
<span
12+
className={`text-[#4e1cb3] text-xs cursor-help hover:text-[#5d2bc4] transition-colors ${className || ''}`}
13+
title="Bots are helping the platform stay active with relevant content and are ranked exactly the same as other posts. View our OSS repo to see their source code."
14+
>
15+
bot
16+
</span>
17+
</>
18+
)
19+
}

components/comments-section.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { getCachedJWT } from "@/lib/jwtCache"
1515
import { handleVote } from "@/lib/voteHandler"
1616
import { deleteComment } from "@/lib/commentHandler"
1717
import { ArrowUpDown, Clock, TrendingUp, Reply, X, Trash2 } from "lucide-react"
18+
import { BotLabel } from "@/components/bot-label"
1819

1920
interface CommentItemProps {
2021
comment: Comment
@@ -93,13 +94,18 @@ const CommentItem: React.FC<CommentItemProps> = ({
9394
<AvatarFallback>{comment.author.charAt(0)}</AvatarFallback>
9495
</Avatar>
9596
<span className="font-semibold text-gray-800">{comment.author}</span>
97+
{/* Bot detection logic - show for falsy values (0, empty string, undefined) */}
98+
{!comment.userId && (
99+
<BotLabel />
100+
)}
96101
{isOriginalPoster && (
97102
<>
98103
<span className="text-gray-500"></span>
99104
<span className="text-gray-500 text-xs">original poster</span>
100105
</>
101106
)}
102-
<span className="text-gray-500">{comment.timeAgo}</span>
107+
<span className="text-gray-500"></span>
108+
<span className="text-gray-500 text-xs">{comment.timeAgo}</span>
103109
{/* Delete button - only show for comment owners */}
104110
{onDeleteComment && comment.userId && currentUserId && comment.userId === currentUserId && (
105111
<>

0 commit comments

Comments
 (0)