diff --git a/plugins/coral-plugin-offtopic/client/actions.js b/plugins/coral-plugin-offtopic/client/actions.js new file mode 100644 index 000000000..6a4ef98d5 --- /dev/null +++ b/plugins/coral-plugin-offtopic/client/actions.js @@ -0,0 +1,5 @@ +import {TOGGLE_CHECKBOX} from './constants'; + +export const toggleCheckbox = () => ({ + type: TOGGLE_CHECKBOX +}); \ No newline at end of file diff --git a/plugins/coral-plugin-offtopic/client/components/OffTopicFilter.js b/plugins/coral-plugin-offtopic/client/components/OffTopicFilter.js index f8c588316..7122bc20f 100644 --- a/plugins/coral-plugin-offtopic/client/components/OffTopicFilter.js +++ b/plugins/coral-plugin-offtopic/client/components/OffTopicFilter.js @@ -2,6 +2,7 @@ import React from 'react'; import styles from './styles.css'; import {connect} from 'react-redux'; import {bindActionCreators} from 'redux'; +import {toggleCheckbox} from '../actions'; import {addClassName, removeClassName} from 'coral-embed-stream/src/actions/comment'; import {closeViewingOptions} from 'coral-embed-stream/src/actions/stream'; @@ -14,9 +15,11 @@ class OffTopicFilter extends React.Component { handleChange = (e) => { if (e.target.checked) { this.props.addClassName(this.cn); + this.props.toggleCheckbox(); } else { - const idx = this.props.comment.classNames.indexOf(this.cn); + const idx = this.props.classNames.findIndex((i) => i[this.className]); this.props.removeClassName(idx); + this.props.toggleCheckbox(); } this.props.closeViewingOptions(); } @@ -25,7 +28,7 @@ class OffTopicFilter extends React.Component { return (