Skip to content

Commit f9db18d

Browse files
committed
chore: fix fetchDiscord CH script
1 parent 7a5a398 commit f9db18d

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/components/DiscordGitComments/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ export const DiscordGitComments: React.FC<CommentProps> = ({ answer, comments, p
7171

7272
{comments &&
7373
comments.map((comment, index) => {
74+
if (!comment) {
75+
return null
76+
}
77+
7478
const totalReplies = comment?.replies ? comment?.replies?.length : false
7579
if (answer && comment?.body === answer?.body) {
7680
return null

src/scripts/fetchDiscord.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ async function fetchFromDiscord(
8484
throw new Error(`Failed to fetch ${endpoint}: ${response.statusText}`)
8585
}
8686

87-
const rawData = await response.json()
88-
const data = rawData.filter((item) => item && item.author && item.content)
87+
const data = await response.json()
8988

9089
if (fetchType === 'threads') {
9190
allResults.push(...(data.threads || []))
@@ -111,8 +110,8 @@ function processMessages(messages: Message[]) {
111110
for (let i = 0; i < messages.length; i++) {
112111
const currentMessage = messages[i]
113112

114-
if (!currentMessage || !currentMessage.author || !currentMessage.content) {
115-
console.warn('Skipping message due to missing author or content:', currentMessage)
113+
if (!currentMessage.author || (!currentMessage.attachments && !currentMessage.content)) {
114+
// Skip messages without content or author
116115
continue
117116
}
118117

0 commit comments

Comments
 (0)