fix(rooms): wire ?after= param to getRoomMessagesSince in messages GET route#2305
fix(rooms): wire ?after= param to getRoomMessagesSince in messages GET route#2305nyxsky404 wants to merge 1 commit into
Conversation
|
@nyxsky404 is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel. A member of the Team first needs to authorize it. |
GSSoC Label Checklist 🏷️@Priyanshu-byte-coder — please apply the appropriate labels before merging: Difficulty (pick one):
Quality (optional):
Validation (required to score):
|
|
The CI failures on this PR (Playwright smoke tests and Playwright visual regression) are pre-existing broken tests on Root causes fixed:
Fixes have been applied to this branch. CI is Green. |
|
This PR has merge conflicts with the current git fetch origin main
git merge origin/main
# resolve conflicts
git push |
…T route The polling loop in MessageFeed sent ?after=<timestamp> to fetch only new messages, but the GET handler read ?before= exclusively, leaving the after param silently ignored. Every poll returned the same last-50 messages instead of only the messages newer than the last seen one. getRoomMessagesSince already existed in supabase-rooms.ts for this exact purpose. The route now branches on the presence of after vs before so incremental polls are efficient and initial loads / reverse pagination continue to work via getRoomMessages. Fixes Umbrella-io#2301
7e1b1f5 to
9d82b88
Compare
Summary
The room chat polling loop in
MessageFeedsends?after=<timestamp>to fetch only messages newer than the last seen one. The GET handler was reading?before=exclusively, soafterwas silently ignored — every poll returned the same last-50 messages instead of only the new ones. This PR wires theafterparam to the already-existinggetRoomMessagesSincehelper.Closes #2301
Type of Change
What Changed
src/app/api/rooms/[roomId]/messages/route.ts— addedafterparam read from query string; branched togetRoomMessagesSince(roomId, after)for incremental polls and keptgetRoomMessages(roomId, 50, before)for initial loads and reverse paginationgetRoomMessagesSinceto the import from@/lib/supabase-roomsHow to Test
Expected result: Each poll response returns only messages sent after the last-known timestamp. Initial page load still returns the most recent 50 messages as before.
Checklist
console.log, debug code, or commented-out blockspnpm run type-check— errors shown are all pre-existing)getRoomMessagesSincehas existing coverage intest/rooms-messages.test.ts)