Skip to content

Link follow to notifications in article pages#15558

Open
aracho1 wants to merge 10 commits intomainfrom
link-follow-to-notifications
Open

Link follow to notifications in article pages#15558
aracho1 wants to merge 10 commits intomainfrom
link-follow-to-notifications

Conversation

@aracho1
Copy link
Contributor

@aracho1 aracho1 commented Mar 19, 2026

What does this change?

  • Couple follow and notifications: Following a contributor now automatically enables notifications, and unfollowing disables them.
  • Auto-follow users with existing notifications: On load, if a user has notifications turned on for a contributor but isn't following them, the tag follow is automatically enabled to keep the two states consistent.
  • Replace the notifications button with a text label that shows the current notification state and directs users to Settings to change it.

Why?

We are making a stronger link between follow and notifications, by making users follow something before they can set notifications for the subject.

Screenshots

Not following Notification On Notification Off
after-iOS-not-following after-iOS-following-on after-iOS-following-off
after-android-not-following after-android-following-on after-android-following-off

@github-actions
Copy link

github-actions bot commented Mar 19, 2026

@github-actions
Copy link

github-actions bot commented Mar 19, 2026

.catch((error) => {
window.guardian.modules.sentry.reportError(
error,
'bridget-getTagClient-auto-follow-error',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've assumed it's ok to create a new Sentry error type for this but please let me know if I should just use an existing one e.g. `'bridget-getTagClient-isFollowing-error'

if (isBridgetCompatible && isMyGuardianEnabled && isNotInBlockList(id)) {
setShowFollowTagButton(true);
}
useEffect(() => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the block list check into a useEffect because the original code was calling setState directly during render

Copy link
Contributor

Choose a reason for hiding this comment

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

Why does showFollowTagButton require a useState? It looks like it depends on four properties:

  1. blockList, which is static and never changes.
  2. id, which is a prop, and will cause a re-render if changed1.
  3. isMyGuardianEnabled, which is a separate state variable, and will cause a re-render if changed2.
  4. isBridgetCompatible, which is a separate state variable, and will cause a re-render if changed.

In other words, it looks like it can entirely derived from these, and can therefore just be a value calculated in the body of the component. 1) cannot change, and any changes to 2), 3) or 4) will cause a re-render that will re-calculate this derived value in the body.

Footnotes

  1. https://react.dev/learn/passing-props-to-a-component#how-props-change-over-time

  2. https://react.dev/reference/react/useState#setstate

@aracho1 aracho1 added the feature Departmental tracking: work on a new feature label Mar 19, 2026
@aracho1 aracho1 marked this pull request as ready for review March 19, 2026 11:14
@github-actions
Copy link

Hello 👋! When you're ready to run Chromatic, please apply the run_chromatic label to this PR.

You will need to reapply the label each time you want to run Chromatic.

Click here to see the Chromatic project.

@aracho1 aracho1 added the run_chromatic Runs chromatic when label is applied label Mar 20, 2026
@github-actions github-actions bot removed the run_chromatic Runs chromatic when label is applied label Mar 20, 2026
Copy link
Contributor

@JamieB-gu JamieB-gu left a comment

Choose a reason for hiding this comment

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

Looks good, one question.

if (isBridgetCompatible && isMyGuardianEnabled && isNotInBlockList(id)) {
setShowFollowTagButton(true);
}
useEffect(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does showFollowTagButton require a useState? It looks like it depends on four properties:

  1. blockList, which is static and never changes.
  2. id, which is a prop, and will cause a re-render if changed1.
  3. isMyGuardianEnabled, which is a separate state variable, and will cause a re-render if changed2.
  4. isBridgetCompatible, which is a separate state variable, and will cause a re-render if changed.

In other words, it looks like it can entirely derived from these, and can therefore just be a value calculated in the body of the component. 1) cannot change, and any changes to 2), 3) or 4) will cause a re-render that will re-calculate this derived value in the body.

Footnotes

  1. https://react.dev/learn/passing-props-to-a-component#how-props-change-over-time

  2. https://react.dev/reference/react/useState#setstate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Departmental tracking: work on a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants