mirror of
https://framagit.org/tykayn/mastodon.git
synced 2023-08-25 08:33:12 +02:00
29 lines
929 B
JavaScript
29 lines
929 B
JavaScript
import { connect } from 'react-redux';
|
|
import ColumnSettings from '../components/column_settings';
|
|
import { changeColumnParams } from 'flavours/glitch/actions/columns';
|
|
import { changeSetting } from 'flavours/glitch/actions/settings';
|
|
|
|
const mapStateToProps = (state, { columnId }) => {
|
|
const uuid = columnId;
|
|
const columns = state.getIn(['settings', 'columns']);
|
|
const index = columns.findIndex(c => c.get('uuid') === uuid);
|
|
|
|
return {
|
|
settings: (uuid && index >= 0) ? columns.get(index).get('params') : state.getIn(['settings', 'community']),
|
|
};
|
|
};
|
|
|
|
const mapDispatchToProps = (dispatch, { columnId }) => {
|
|
return {
|
|
onChange (key, checked) {
|
|
if (columnId) {
|
|
dispatch(changeColumnParams(columnId, key, checked));
|
|
} else {
|
|
dispatch(changeSetting(['community', ...key], checked));
|
|
}
|
|
},
|
|
};
|
|
};
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(ColumnSettings);
|