#3433 Fix rendering issue when comments/notifications are added via SSE
Closed: Fixed 5 years ago Opened 5 years ago by pingou.

SSE are Server Sent Event, they are ways to update the content of the page without reloading it entirely.
We use this on pagure.io via the EventSource protocol which is http and JS based.

To get the SSE working,
- add to your config file:

EVENTSOURCE_SOURCE = 'http://127.0.0.1:8080'
EVENTSOURCE_PORT = '8080'
  • starts the SSE server with: PYTHONPATH=. PAGURE_CONFIG=`pwd`/config python pagure-ev/pagure_stream_server.py (where config is your local configuration file)
  • Start the flask server as usual via: runserver.py -c config --debug (same comment as above about config)

You can then see the SSE in action by opening a ticket or a PR in two windows in your browser. Adding a comment to the page in one of the window will make it appear automatically on the other.

However, since we've redesigned the issue and PR pages, the HTML added via SSE no longer fit with the rest of the page. So we should update it as well :)


Would it make sense to change the server side to render the snippet into HTML and send that to client side? If it could reuse the same template, this would not be a problem anymore, and would simplify the javascript quite significantly.

The data has to be JSON, but we could embed the HTML in it I guess :)

Note that, when we can't connect to the EV but there is one running (for example on pagure.io stunnel has too many connections, or you have too many tabs open with persistent connection to the same domain (which browsers don't like)), we fall back to send the form via ajax and show the comment via JS (as if it was EV but not quite either).
This uses the JS code used to render comment sent via SSE, so if we send html directly via SSE, we'll need to find a way to display comments properly when the SSE server isn't responding.

Cf PR #3112 and #3183

the PR #3485 pretty much fixes this for issue comments.

still need to fix PR comments.

Login to comment on this ticket.

Metadata
Related Pull Requests
  • #3499 Merged 5 years ago