mirror of
https://framagit.org/tykayn/mastodon.git
synced 2023-08-25 08:33:12 +02:00
33 lines
1.0 KiB
JavaScript
33 lines
1.0 KiB
JavaScript
import { connect } from 'react-redux';
|
|
import ColumnSettings from '../components/column_settings';
|
|
import { changeColumnParams } from 'flavours/glitch/actions/columns';
|
|
import api from 'flavours/glitch/util/api';
|
|
|
|
const mapStateToProps = (state, { columnId }) => {
|
|
const columns = state.getIn(['settings', 'columns']);
|
|
const index = columns.findIndex(c => c.get('uuid') === columnId);
|
|
|
|
if (!(columnId && index >= 0)) {
|
|
return {};
|
|
}
|
|
|
|
return {
|
|
settings: columns.get(index).get('params'),
|
|
onLoad (value) {
|
|
return api(() => state).get('/api/v2/search', { params: { q: value, type: 'hashtags' } }).then(response => {
|
|
return (response.data.hashtags || []).map((tag) => {
|
|
return { value: tag.name, label: `#${tag.name}` };
|
|
});
|
|
});
|
|
},
|
|
};
|
|
};
|
|
|
|
const mapDispatchToProps = (dispatch, { columnId }) => ({
|
|
onChange (key, value) {
|
|
dispatch(changeColumnParams(columnId, key, value));
|
|
},
|
|
});
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(ColumnSettings);
|