mirror of
https://github.com/wassname/talk.git
synced 2026-08-13 12:40:11 +08:00
update constant names
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
import coralApi from '../helpers/response';
|
||||
import {addItem} from './items';
|
||||
|
||||
export const FETCH_MULTIPLE_ASSETS = 'FETCH_MULTIPLE_ASSETS';
|
||||
export const RECEIVE_MULTIPLE_ASSETS = 'RECEIVE_MULTIPLE_ASSETS';
|
||||
export const FAILURE_MULTIPLE_ASSSETS = 'FAILURE_MULTIPLE_ASSSETS';
|
||||
export const MULTIPLE_ASSETS_REQUEST = 'MULTIPLE_ASSETS_REQUEST';
|
||||
export const MULTIPLE_ASSETS_SUCCESS = 'MULTIPLE_ASSETS_SUCCESS';
|
||||
export const MULTIPLE_ASSSETS_FAILURE = 'MULTIPLE_ASSSETS_FAILURE';
|
||||
|
||||
export const fetchMulitpleAssets = ids => {
|
||||
return dispatch => {
|
||||
dispatch({type: FETCH_MULTIPLE_ASSETS});
|
||||
dispatch({type: MULTIPLE_ASSETS_REQUEST});
|
||||
|
||||
coralApi(`/assets/multi?ids=${encodeURIComponent(ids.join(','))}`)
|
||||
.then(assets => {
|
||||
assets.forEach(asset => dispatch(addItem(asset, 'assets')));
|
||||
dispatch({type: RECEIVE_MULTIPLE_ASSETS, assets: assets.map(asset => asset.id)});
|
||||
dispatch({type: MULTIPLE_ASSETS_SUCCESS, assets: assets.map(asset => asset.id)});
|
||||
})
|
||||
.catch(error => dispatch({type: FAILURE_MULTIPLE_ASSSETS, error}));
|
||||
.catch(error => dispatch({type: MULTIPLE_ASSSETS_FAILURE, error}));
|
||||
};
|
||||
};
|
||||
|
||||
@@ -30,19 +30,19 @@ export const saveBio = (user_id, formData) => dispatch => {
|
||||
*/
|
||||
export const fetchCommentsByUserId = userId => {
|
||||
return (dispatch) => {
|
||||
dispatch({type: actions.REQUEST_COMMENTS_BY_USER});
|
||||
dispatch({type: actions.COMMENTS_BY_USER_REQUEST});
|
||||
return coralApi(`/comments?user_id${userId}`)
|
||||
.then(({comments}) => {
|
||||
comments.forEach(comment => {
|
||||
dispatch(addItem(comment, 'comments'));
|
||||
});
|
||||
|
||||
dispatch({type: actions.RECEIVE_COMMENTS_BY_USER, comments: comments.map(comment => comment.id)});
|
||||
dispatch({type: actions.COMMENTS_BY_USER_SUCCESS, comments: comments.map(comment => comment.id)});
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error.stack);
|
||||
console.error('FAILURE_COMMENTS_BY_USER', error);
|
||||
dispatch({type: actions.FAILURE_COMMENTS_BY_USER, error});
|
||||
dispatch({type: actions.COMMENTS_BY_USER_FAILURE, error});
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
export const SAVE_BIO_REQUEST = 'SAVE_BIO_REQUEST';
|
||||
export const SAVE_BIO_SUCCESS = 'SAVE_BIO_SUCCESS';
|
||||
export const SAVE_BIO_FAILURE = 'SAVE_BIO_FAILURE';
|
||||
export const REQUEST_COMMENTS_BY_USER = 'REQUEST_COMMENTS_BY_USER';
|
||||
export const RECEIVE_COMMENTS_BY_USER = 'RECEIVE_COMMENTS_BY_USER';
|
||||
export const FAILURE_COMMENTS_BY_USER = 'FAILURE_COMMENTS_BY_USER';
|
||||
export const COMMENTS_BY_USER_REQUEST = 'COMMENTS_BY_USER_REQUEST';
|
||||
export const COMMENTS_BY_USER_SUCCESS = 'COMMENTS_BY_USER_SUCCESS';
|
||||
export const COMMENTS_BY_USER_FAILURE = 'COMMENTS_BY_USER_FAILURE';
|
||||
|
||||
@@ -33,9 +33,9 @@ export default function user (state = initialState, action) {
|
||||
case actions.SAVE_BIO_SUCCESS:
|
||||
return state
|
||||
.set('settings', action.settings);
|
||||
case actions.RECEIVE_COMMENTS_BY_USER:
|
||||
case actions.COMMENTS_BY_USER_SUCCESS:
|
||||
return state.set('myComments', fromJS(action.comments));
|
||||
case assetActions.RECEIVE_MULTIPLE_ASSETS:
|
||||
case assetActions.MULTIPLE_ASSETS_SUCCESS:
|
||||
return state.set('myAssets', fromJS(action.assets));
|
||||
default :
|
||||
return state;
|
||||
|
||||
Reference in New Issue
Block a user