mirror of
https://github.com/wassname/talk.git
synced 2026-07-20 12:40:47 +08:00
Loading assets and adding to store.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
export const ASSETS_FETCH = 'ASSETS_FETCH';
|
||||
@@ -1,6 +1,8 @@
|
||||
import React, {Component} from 'react';
|
||||
import styles from './Streams.css';
|
||||
import {connect} from 'react-redux';
|
||||
import I18n from 'coral-framework/modules/i18n/i18n';
|
||||
import {ASSETS_FETCH} from '../../constants/assets';
|
||||
import translations from '../../translations.json';
|
||||
import {
|
||||
RadioGroup,
|
||||
@@ -18,6 +20,10 @@ class Streams extends Component {
|
||||
statusFilter: 'all'
|
||||
}
|
||||
|
||||
componentDidMount () {
|
||||
this.props.fetchAssets(0, 25, '', 'desc');
|
||||
}
|
||||
|
||||
onSettingChange = (setting) => (e) => {
|
||||
this.setState({[setting]: e.target.value});
|
||||
}
|
||||
@@ -90,6 +96,21 @@ class Streams extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
export default Streams;
|
||||
const mapStateToProps = () => {};
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
fetchAssets: (skip, limit, search, sort) => {
|
||||
dispatch({
|
||||
type: ASSETS_FETCH,
|
||||
skip,
|
||||
limit,
|
||||
search,
|
||||
sort
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(Streams);
|
||||
|
||||
const lang = new I18n(translations);
|
||||
|
||||
@@ -4,6 +4,7 @@ import settings from 'reducers/settings';
|
||||
import community from 'reducers/community';
|
||||
import users from 'reducers/users';
|
||||
import auth from 'reducers/auth';
|
||||
import assets from 'reducers/assets';
|
||||
|
||||
// Combine all reducers into a main one
|
||||
export default combineReducers({
|
||||
@@ -11,5 +12,6 @@ export default combineReducers({
|
||||
comments,
|
||||
community,
|
||||
auth,
|
||||
users
|
||||
users,
|
||||
assets
|
||||
});
|
||||
|
||||
@@ -20,8 +20,8 @@ router.get('/', (req, res, next) => {
|
||||
Asset
|
||||
.search(search)
|
||||
.sort({[field]: (sort === 'asc') ? 1 : -1})
|
||||
.skip(skip)
|
||||
.limit(limit),
|
||||
.skip(parseInt(skip))
|
||||
.limit(parseInt(limit)),
|
||||
Asset
|
||||
.search(search)
|
||||
.count()
|
||||
|
||||
Reference in New Issue
Block a user