Add dismiss (x) for unread news items in news listing#2764
Conversation
Allows users to dismiss the "unread" status of news items directly from the news listing page using a little (x) link in the pill. Modified handlers/news/label_tasks.go to support redirect param via GET. Modified core/templates/site/news/post.gohtml to render the dismiss link. Added unit tests for verification. Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
@jules this can be ajax returning a html part which is replaced by replacing an id (which changes each replacement.) |
I have implemented the AJAX dismissal as requested. The link now uses an |
- Modified core/templates/site/news/post.gohtml to add dismiss link with AJAX support - Updated handlers/news/label_tasks.go to handle AJAX requests - Added dismissUnread function to core/templates/assets/site.js - Added unit tests for AJAX handling and template rendering Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
There was a problem hiding this comment.
@jules I'm expecting to see the replaceable section having a randomly generated ID, and the URL having that same randomly generated ID, and the JS using that randomly generated id to replace it. This way ensures that a double update doesn't happen (actually thinking about it in this case it should be the server excution time, if it's later then replace. So the ID needs to remains static in the return and not replaced with a random, but a timestamp component needs to be returned and the replacement only happens if the timestamp is greater.
There was a problem hiding this comment.
I have updated the implementation to use a static ID with a timestamp check to prevent race conditions. The server now returns the updated label list HTML with a timestamp, and the client-side JavaScript replaces the content only if the new timestamp is greater than the current one.
- Modified `core/templates/site/news/post.gohtml` to wrap labels in a container with a static ID and timestamp. - Updated `handlers/news/label_tasks.go` to return the rendered label template with updated data. - Updated `core/templates/assets/site.js` to implement `replaceContent` with timestamp validation. - Updated tests to verify the new behavior. Co-authored-by: arran4 <111667+arran4@users.noreply.github.com>
Add dismiss (x) for unread news items in news listing
PR created automatically by Jules for task 3425729363872353639 started by @arran4