feat(listings): implement live reload for new listings using SSE#361
Conversation
| try { | ||
| const data = JSON.parse(e.data || '{}'); | ||
| if (data && data.count) { | ||
| loadDataRef.current(); |
There was a problem hiding this comment.
If I understand correctly, you call the loadData function, so you got the new listings via sse, still load everything? What if a user is currently checking something on page 2? This would route the user back to page 1 and could be pretty confusing? How about instead showing a small popover at the top of the current view: "There's new data available, click here to reload"
There was a problem hiding this comment.
Yea I thought about that issue too. It's a bit different tho, if a user is on page 2 (or has filters applied or whatever) it would reload page 2. That still would mean that it changes the page slightly.
I thought a live reload is nicer because it happens automatic, but I get your point.
What if we live reload only if a user is on page 1, otherwise show a toast/popover? Or do you wanna stick to the popover for all cases?
There was a problem hiding this comment.
I think having it consistent would be better, so showing a popover..
Thanks
There was a problem hiding this comment.
Done, I've added the Banner which is also used elsewhere above the table
This PR implements real-time silent live-reloading for the listings overview page.
Currently when new listings are fetched and stored by background/scheduled jobs, users on the Listings page do not see them unless they manually reload the page. This breaks the seamless real-time feel of the application.
Solution:
We leverage Fredys existing SSE architecture to silently reload the listings state in the background.
Backend:
listings:newevent through SSE to the user when new listings are added to the databaseFrontend:
/api/jobs/eventsSSE channellistings:newevent is received