Skip to content

Add dismiss (x) for unread news items in news listing#2764

Merged
arran4 merged 3 commits into
mainfrom
news-dismiss-unread-3425729363872353639
Feb 5, 2026
Merged

Add dismiss (x) for unread news items in news listing#2764
arran4 merged 3 commits into
mainfrom
news-dismiss-unread-3425729363872353639

Conversation

@arran4

@arran4 arran4 commented Feb 4, 2026

Copy link
Copy Markdown
Owner

Add dismiss (x) for unread news items in news listing


PR created automatically by Jules for task 3425729363872353639 started by @arran4

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>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@arran4

arran4 commented Feb 4, 2026

Copy link
Copy Markdown
Owner Author

@jules this can be ajax returning a html part which is replaced by replacing an id (which changes each replacement.)

@google-labs-jules

Copy link
Copy Markdown
Contributor

@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 onclick handler to fetch the URL with an ajax=1 parameter, and the backend handler returns an empty response to remove the element. I also ensured graceful degradation by removing the ajax=1 from the href attribute.

- 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>

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>

@arran4 arran4 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@arran4 arran4 merged commit fac2426 into main Feb 5, 2026
3 of 13 checks passed
@arran4 arran4 deleted the news-dismiss-unread-3425729363872353639 branch February 5, 2026 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant