feat: add chat message history and infinite scroll
Backend changes: - Socket.IO: Send last 20 messages on join_event_room - REST API: Add GET /api/events/:eventId/messages endpoint with pagination - Support for 'before' cursor-based pagination for loading older messages Frontend changes: - Load initial 20 messages when joining event chat - Implement infinite scroll to load older messages on scroll to top - Add loading indicator for older messages - Preserve scroll position when loading older messages - Add eventsAPI.getMessages() function for pagination User experience: - New users see last 20 messages immediately - Scrolling up automatically loads older messages in batches of 20 - Smooth scrolling experience with position restoration Note: Messages are encrypted in transit via HTTPS/WSS but stored as plain text in database (no E2E encryption).
This commit is contained in:
@@ -163,6 +163,15 @@ export const eventsAPI = {
|
||||
const data = await fetchAPI(`/events/${id}`);
|
||||
return data.data;
|
||||
},
|
||||
|
||||
async getMessages(eventId, before = null, limit = 20) {
|
||||
const params = new URLSearchParams({ limit: limit.toString() });
|
||||
if (before) {
|
||||
params.append('before', before.toString());
|
||||
}
|
||||
const data = await fetchAPI(`/events/${eventId}/messages?${params}`);
|
||||
return data;
|
||||
},
|
||||
};
|
||||
|
||||
export { ApiError };
|
||||
|
||||
Reference in New Issue
Block a user