The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

32 lines
961 B

  1. import { connect } from 'react-redux';
  2. import ColumnSettings from '../components/column_settings';
  3. import { changeColumnParams } from '../../../actions/columns';
  4. import api from '../../../api';
  5. const mapStateToProps = (state, { columnId }) => {
  6. const columns = state.getIn(['settings', 'columns']);
  7. const index = columns.findIndex(c => c.get('uuid') === columnId);
  8. if (!(columnId && index >= 0)) {
  9. return {};
  10. }
  11. return { settings: columns.get(index).get('params') };
  12. };
  13. const mapDispatchToProps = (dispatch, { columnId }) => ({
  14. onChange (key, value) {
  15. dispatch(changeColumnParams(columnId, key, value));
  16. },
  17. onLoad (value) {
  18. return api().get('/api/v2/search', { params: { q: value } }).then(response => {
  19. return (response.data.hashtags || []).map((tag) => {
  20. return { value: tag.name, label: `#${tag.name}` };
  21. });
  22. });
  23. },
  24. });
  25. export default connect(mapStateToProps, mapDispatchToProps)(ColumnSettings);