UNPKG

nyx_server

Version:

Node内容发布

33 lines (28 loc) 971 B
import { connect } from 'react-redux'; import Chips from '../components/Chips'; import {setChipDataId} from '../actions/Project'; function saveToLocal(storageName, id, basePath) { if (window.localStorage) { var data = JSON.parse(window.localStorage.getItem(storageName) || '{}'); data[basePath] = id; window.localStorage.setItem(storageName, JSON.stringify(data)); } } function select (state) { var name = state.project.get('currentProject'); return { chips: state.project.getIn(['cache', name, 'data', 'chips']), isLoading: state.project.getIn(['cache', name, 'isLoading']), error: state.project.getIn(['cache', name, 'error']), dataIds: state.project.get('chipsDataIds') }; } function actionSelect(dispatch) { return { onChangeId: (id, basePath) => { saveToLocal('nyxChipsDataIds', id, basePath); return dispatch(setChipDataId(id, basePath)); } }; } export default connect(select, actionSelect)(Chips);