Skip to content

Add 'unsubscribe from thread' action to Reply notifications - #2943

Open
Hardeezah wants to merge 1 commit into
stackernews:masterfrom
Hardeezah:unsubscribe-thread-notification
Open

Add 'unsubscribe from thread' action to Reply notifications#2943
Hardeezah wants to merge 1 commit into
stackernews:masterfrom
Hardeezah:unsubscribe-thread-notification

Conversation

@Hardeezah

Copy link
Copy Markdown

Closes #2578

Add unsubscribeThread mutation
Add "unsubscribe from thread" action link under Reply notifications

Description

This PR adds an "Unsubscribe from thread" feature directly in the notifications page. It allows users to easily stop receiving notifications from long or noisy reply chains by unsubscribing from the current item and all its ancestors in one click.

Key changes:

  • Added unsubscribeThread(id: ID!): Item mutation to the GraphQL schema
  • Implemented the resolver using PostgreSQL’s ltree @> operator to efficiently delete all ancestor ThreadSubscription records in a single query
  • Updated the Reply notification component to display a small “unsubscribe from thread” link with immediate feedback (hides after success + toast message)

Screenshots

unsubscribe from thread

“unsubscribe from thread” action visible under Reply notifications

Additional Context

The mutation follows the existing tree structure patterns in the codebase using ltree path matching. This provides a much better user experience when dealing with notification spam from active comment threads.

Checklist

Are your changes backward compatible? Please answer below:

Yes. No breaking changes to the GraphQL API or database schema.

On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:

9/10. Tested full subscription → notification → unsubscribe flow, verified database cleanup, confirmed no new notifications arrive after unsubscribing, and ran linting and tests.

For frontend changes: Tested on mobile, light and dark mode? Please answer below:

Yes. The UI uses existing Bootstrap utility classes and works correctly across mobile, desktop, light, and dark modes.

Did you introduce any new environment variables? If so, call them out explicitly here:

No.

Did you use AI for this? If so, how much did it assist you?

Yes, used for code review

Closes stackernews#2578

- Add unsubscribeThread mutation
- Add action link under Reply notifications
@Hardeezah

Copy link
Copy Markdown
Author

@huumn This implements #2578. Ready for review.

@zhailong8845-art zhailong8845-art left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The new action is rendered as a <span onClick>, so it cannot be reached with Tab and cannot be activated with Enter or Space. That makes the only way to unsubscribe from a notification unavailable to keyboard-only users (and the element exposes no button semantics to assistive technology). Please render this as a real button type="button" styled like a link, or use the project’s existing accessible action component, while preserving the current mutation/error behavior.

@zhailong8845-art

This comment was marked as spam.

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.

Unsubscribe from parents / thread

2 participants