-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Live removal of issue comments using htmx websocket #28958
base: main
Are you sure you want to change the base?
Conversation
I will wait with further development until #28880 has a final decision for now. Just wanted to do this POC to see and show the team if it could be used for the discussed realtime topics as well. |
Wouldn't we say htmx will be used on simple situation? I think this page is very complex. |
I agree with lunny, this is more complex than I imagined but hey, if it works that's awesome. Do we really have 2 way communication here though? Maybe SSE fits better for this use case |
This comment was marked as resolved.
This comment was marked as resolved.
We need a Websocket in any case as SSE is too limiting:
|
Is it fine to hook into |
I think it should be. You need to implemente a new notifier like notification. |
Okay, I adjusted the code a bit so it sends messages through pubsub and to use subscriptions instead of the for loop iterating the sessions. I currently see two options how the initial notifier event could be brought to a websocket client. What do you think?
|
return | ||
} | ||
|
||
n.pubsub.Publish(ctx, pubsub.Message{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the topic should still contain the issue and index. And it also includes the actions like delete/create/update. Because I think different pages of the same clients should not share the same web socket client.
services/websocket/websocket.go
Outdated
} | ||
|
||
ctx := goContext.Background() // TODO: use proper context | ||
h.pubsub.Subscribe(ctx, msgData.Repo, func(msg pubsub.Message) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When an anonymous user are staying on an issue view page, shouldn't the page will be automatically updated?
First step into "realtime" updating UI using htmx with ws extension as discussed in #2287 and #25661
As rendering comments was quite tough (a lot of code changes) I just implemented the updating UI part for removing a comment for now as a reference. All other events will be quite simple to add from now on and only require some rendering logic to be adjusted.
htxm logic based on #28908
websocket logic based on #26679 and #27806
Screencast.from.2024-02-16.17-50-20.webm
How it works:
/-/ws
dom.load
:{ action: "subscrib", data: { url: "http://localhost:3000/anbraten/test/issues/1"}}
to the server to let it know it is interested in updates relevant for this pageTODO