Skip to content
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

Invert the option on the UI for easier understanding #97146

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions client/me/notification-settings/reader-subscriptions/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ class NotificationSubscriptions extends Component {
return () => this.props.recordGoogleEvent( 'Me', 'Focused on ' + action );
}

handleCheckboxEvent( action ) {
handleCheckboxEvent( action, invert = false ) {
return ( event ) => {
const eventAction = 'Clicked ' + action + ' checkbox';
const optionValue = event.target.checked ? 1 : 0;

this.props.recordGoogleEvent( 'Me', eventAction, 'checked', optionValue );
const optionValue = invert ? ! event.target.checked : event.target.checked;
this.props.recordGoogleEvent( 'Me', `Clicked ${ action } checkbox`, 'checked', +optionValue );
Copy link
Member

Choose a reason for hiding this comment

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

This kind of integer conversion is a bit more idiomatic, but I appreciate the brevity 👍

};
}

Expand Down Expand Up @@ -243,21 +241,21 @@ class NotificationSubscriptions extends Component {

{ isAutomattician && (
<FormFieldset>
<FormLegend>
Disable auto-follow P2 posts upon commenting (Automatticians only)
</FormLegend>
<FormLegend>Auto-follow P2 posts (Automatticians only)</FormLegend>
<FormLabel>
<FormCheckbox
checked={ this.props.getSetting( 'p2_disable_autofollow_on_comment' ) }
checked={ ! this.props.getSetting( 'p2_disable_autofollow_on_comment' ) }
disabled={ this.props.getDisabledState() }
id="p2_disable_autofollow_on_comment"
name="p2_disable_autofollow_on_comment"
onChange={ this.props.toggleSetting }
onClick={ this.handleCheckboxEvent( 'Disable auto-follow P2 Upon Comment' ) }
onClick={ this.handleCheckboxEvent(
'Enable auto-follow P2 Upon Comment',
bor0 marked this conversation as resolved.
Show resolved Hide resolved
true
) }
/>
<span>
Don't automatically subscribe to notifications for a P2 post whenever you leave
a comment on it.
Automatically subscribe to P2 post notifications when you leave a comment.
</span>
</FormLabel>
</FormFieldset>
Expand Down
Loading