From 147f7ed878b5c233b4a118948e27cb819beb4d4b Mon Sep 17 00:00:00 2001 From: mgabdev <> Date: Tue, 1 Sep 2020 14:54:17 -0500 Subject: [PATCH] Updated Switch to return boolean instead of event MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Updated: - Switch to return boolean instead of event - all components usage --- .../gabsocial/components/modal/edit_profile_modal.js | 4 ++-- app/javascript/gabsocial/components/setting_switch.js | 5 ++--- app/javascript/gabsocial/components/status_check_box.js | 4 ++-- app/javascript/gabsocial/components/switch.js | 6 +++++- app/javascript/gabsocial/features/group_create.js | 8 ++++---- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/app/javascript/gabsocial/components/modal/edit_profile_modal.js b/app/javascript/gabsocial/components/modal/edit_profile_modal.js index af8f8250..693a7e43 100644 --- a/app/javascript/gabsocial/components/modal/edit_profile_modal.js +++ b/app/javascript/gabsocial/components/modal/edit_profile_modal.js @@ -71,8 +71,8 @@ class EditProfileModal extends ImmutablePureComponent { this.setState({ bioValue: value }) } - handleLockedChange = ({ target }) => { - this.setState({ locked: target.checked }) + handleLockedChange = (locked) => { + this.setState({ locked }) } handleOnClose = () => { diff --git a/app/javascript/gabsocial/components/setting_switch.js b/app/javascript/gabsocial/components/setting_switch.js index 25f8e1db..a68683da 100644 --- a/app/javascript/gabsocial/components/setting_switch.js +++ b/app/javascript/gabsocial/components/setting_switch.js @@ -14,8 +14,8 @@ class SettingSwitch extends ImmutablePureComponent { 'label', ] - onChange = ({ target }) => { - this.props.onChange(this.props.settingPath, target.checked) + onChange = (checked) => { + this.props.onChange(this.props.settingPath, checked) } render () { @@ -39,7 +39,6 @@ class SettingSwitch extends ImmutablePureComponent { id={id} checked={checked} onChange={this.onChange} - onKeyDown={this.onKeyDown} /> ) } diff --git a/app/javascript/gabsocial/components/status_check_box.js b/app/javascript/gabsocial/components/status_check_box.js index bcbc7794..434cecfa 100644 --- a/app/javascript/gabsocial/components/status_check_box.js +++ b/app/javascript/gabsocial/components/status_check_box.js @@ -74,8 +74,8 @@ const mapStateToProps = (state, { id }) => ({ }) const mapDispatchToProps = (dispatch, { id }) => ({ - onToggle(e) { - dispatch(toggleStatusReport(id, e.target.checked)) + onToggle(checked) { + dispatch(toggleStatusReport(id, checked)) }, }) diff --git a/app/javascript/gabsocial/components/switch.js b/app/javascript/gabsocial/components/switch.js index 30d8f9d8..9760cdde 100644 --- a/app/javascript/gabsocial/components/switch.js +++ b/app/javascript/gabsocial/components/switch.js @@ -5,6 +5,10 @@ import Text from './text' class Switch extends React.PureComponent { + handleOnChange = (e) => { + this.props.onChange(e.currentTarget.checked) + } + render() { const { id, @@ -51,7 +55,7 @@ class Switch extends React.PureComponent { ) diff --git a/app/javascript/gabsocial/features/group_create.js b/app/javascript/gabsocial/features/group_create.js index f29b91e2..025b1e9b 100644 --- a/app/javascript/gabsocial/features/group_create.js +++ b/app/javascript/gabsocial/features/group_create.js @@ -320,11 +320,11 @@ const mapDispatchToProps = (dispatch) => ({ onChangeGroupCategory(e) { dispatch(changeGroupCategory(e.target.value)) }, - onChangeGroupIsPrivate(value) { - dispatch(changeGroupIsPrivate(value)) + onChangeGroupIsPrivate(checked) { + dispatch(changeGroupIsPrivate(checked)) }, - onChangeGroupIsVisible(value) { - dispatch(changeGroupIsVisible(value)) + onChangeGroupIsVisible(checked) { + dispatch(changeGroupIsVisible(checked)) }, onResetEditor() { dispatch(resetEditor())