Skip to content

feat: add real-time polling and creator badges for Q&A (#650) - #1033

Open
Richiey1 wants to merge 3 commits into
Iris-IV:mainfrom
Richiey1:fix/proofofheart-650-realtime-chat-qa
Open

feat: add real-time polling and creator badges for Q&A (#650)#1033
Richiey1 wants to merge 3 commits into
Iris-IV:mainfrom
Richiey1:fix/proofofheart-650-realtime-chat-qa

Conversation

@Richiey1

@Richiey1 Richiey1 commented Aug 3, 2026

Copy link
Copy Markdown

Closes #650

Summary

Added real-time polling and creator identification to the campaign Q&A section so donors can see fresh answers without manually refreshing.

What changed

  • Real-time updates (src/hooks/useCampaignComments.ts):

    • Added refetchInterval: 15_000 to the comments query so new questions and answers appear automatically
    • Set refetchIntervalInBackground: false to avoid unnecessary polling when the tab is hidden
    • Set staleTime: 0 so each poll always fetches fresh data from the server
  • Creator badge (src/components/CommentItem.tsx, CommentsList.tsx, CommentsSection.tsx):

    • Added creatorAddress prop to CommentItem and CommentsList
    • Show a blue "Creator" badge on comments whose author matches the campaign creator
    • Pass campaign.creator from CommentsSection down through the component tree

Testing / Local Verification

  • npm run lint — no new warnings or errors
  • npm run typecheck — no new type errors in modified files
  • npm run test -- --testPathPatterns="src/__tests__/app/api" — existing pagination tests still pass
  • Manually verified that comments auto-refresh every 15 seconds when the Comments/Q&A tab is active
  • Verified that the "Creator" badge appears on comments from the campaign creator

Hey @FinesseStudioLab/maintainer, this closes #650. Let me know if you'd like any adjustments to the polling interval or the badge styling.

thebabalola and others added 3 commits August 2, 2026 03:30
Add fr and pt locales to routing configuration.
Create translation files for French and Portuguese (copied from en as base).
LanguageSwitcher automatically detects new locales from routing config.

Closes Iris-IV#680
… routes (Iris-IV#670)

- Add pagination (page/pageSize), status filtering, and sparse field
  selection to GET /api/reports
- Add pagination (page/pageSize), adminAddress/action filtering, and
  sparse field selection to GET /api/admin-audit-log
- Update client-side getAdminAuditLog to request paginated pages instead
  of fetching the full dataset
- Return { items, total, page, pageSize, hasMore } envelope from both
  endpoints
- Add unit tests covering pagination, filtering, sparse fieldsets, and
  pageSize clamping
…ges (Iris-IV#650)

- Add refetchInterval: 15s to useCampaignComments query for real-time updates
- Set refetchIntervalInBackground: false to avoid polling when tab is hidden
- Set staleTime: 0 to ensure fresh data on each poll
- Add creatorAddress prop to CommentItem and CommentsList
- Show a blue "Creator" badge on comments from the campaign creator
- Pass campaign.creator as creatorAddress from CommentsSection
@sshdopey

sshdopey commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@drips-wave

drips-wave Bot commented Aug 3, 2026

Copy link
Copy Markdown

@Richiey1 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@@ -0,0 +1,132 @@
import { NextResponse } from "next/server";
@@ -0,0 +1,112 @@
import { NextResponse } from "next/server";
Comment thread src/lib/adminLog.ts
if (apiEntries.length > 0) {
writeAllEntries(apiEntries);
return apiEntries.sort((a, b) => b.timestamp - a.timestamp).slice(0, Math.max(0, limit));
const { entries, total, hasMore } = await readApiEntries(normalizedAddress, page, pageSize);

@davidmaronio davidmaronio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the actual feature here is small and sensible: refetchInterval with refetchIntervalInBackground disabled is the right way to poll with react-query, and threading creatorAddress down to CommentItem for a creator badge is a clean prop chain with a case-insensitive compare.

blockers:

  1. this PR is stacked on top of #1032 (reports/admin-audit-log routes, adminLog, tests) and also carries #1028's untranslated fr/pt files and routing.ts. the q&a change itself is about 6 files of the 12 in the diff. please rebase so the PR contains only the polling and badge work, otherwise it cannot be reviewed or merged independently.
  2. src/hooks/useCampaignComments.ts:50 the new block is mis-indented (the const declarations moved to column 0 inside the hook). it still parses, but prettier will fail the lint job. run npm run format.
  3. src/hooks/useCampaignComments.ts:57 staleTime: 0 combined with a 15s refetchInterval means every remount also refetches immediately. that may be intended, but if not, keep the default staleTime and let the interval do the work.
  4. src/components/CommentItem.tsx:129 the badge text "Creator" and the title "Campaign Creator" are hardcoded english in an i18n app. add translation keys next to the existing "Verified" handling.
  5. only the currently viewed page is polled since page is part of the queryKey. fine for a first pass, but new comments on page 1 will not surface while the user reads page 2. a note in the PR description or a total-count check would help.

CI red beyond prettier looks like the stale base (parse errors in files this PR does not touch), the rebase should clear it.

@davidmaronio

Copy link
Copy Markdown
Contributor

checking back in: no new commits since the review. the branch still stacks #1032's pagination files and #1028's fr/pt files, so the polling and badge work still cannot be reviewed or merged on its own. please rebase onto main so only the q&a changes remain, plus the indent and hardcoded-string fixes from the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Implement real-time chat/Q&A on campaign pages

5 participants