From 4b063607ab2452f77403b30c1f7ef3b28f7e0ca4 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Wed, 21 Jun 2017 20:04:38 +0700 Subject: [PATCH] Return the returns --- client/coral-admin/src/actions/assets.js | 4 ++-- client/coral-admin/src/actions/community.js | 9 ++++----- client/coral-admin/src/actions/install.js | 2 +- client/coral-admin/src/actions/users.js | 6 +++--- client/coral-framework/actions/auth.js | 4 ++-- client/coral-framework/actions/user.js | 2 +- 6 files changed, 13 insertions(+), 14 deletions(-) diff --git a/client/coral-admin/src/actions/assets.js b/client/coral-admin/src/actions/assets.js index 369305dc8..75bd2477d 100644 --- a/client/coral-admin/src/actions/assets.js +++ b/client/coral-admin/src/actions/assets.js @@ -19,7 +19,7 @@ import t from 'coral-framework/services/i18n'; // Get comments to fill each of the three lists on the mod queue export const fetchAssets = (skip = '', limit = '', search = '', sort = '', filter = '') => (dispatch) => { dispatch({type: FETCH_ASSETS_REQUEST}); - coralApi(`/assets?skip=${skip}&limit=${limit}&sort=${sort}&search=${search}&filter=${filter}`) + return coralApi(`/assets?skip=${skip}&limit=${limit}&sort=${sort}&search=${search}&filter=${filter}`) .then(({result, count}) => dispatch({type: FETCH_ASSETS_SUCCESS, assets: result, @@ -36,7 +36,7 @@ export const fetchAssets = (skip = '', limit = '', search = '', sort = '', filte // Get comments to fill each of the three lists on the mod queue export const updateAssetState = (id, closedAt) => (dispatch) => { dispatch({type: UPDATE_ASSET_STATE_REQUEST}); - coralApi(`/assets/${id}/status`, {method: 'PUT', body: {closedAt}}) + return coralApi(`/assets/${id}/status`, {method: 'PUT', body: {closedAt}}) .then(() => dispatch({type: UPDATE_ASSET_STATE_SUCCESS})) .catch((error) => { console.error(error); diff --git a/client/coral-admin/src/actions/community.js b/client/coral-admin/src/actions/community.js index 826594868..ddae062a4 100644 --- a/client/coral-admin/src/actions/community.js +++ b/client/coral-admin/src/actions/community.js @@ -52,17 +52,16 @@ export const newPage = () => ({ }); export const setRole = (id, role) => (dispatch) => { - - coralApi(`/users/${id}/role`, {method: 'POST', body: {role}}) + return coralApi(`/users/${id}/role`, {method: 'POST', body: {role}}) .then(() => { - dispatch({type: SET_ROLE, id, role}); + return dispatch({type: SET_ROLE, id, role}); }); }; export const setCommenterStatus = (id, status) => (dispatch) => { - coralApi(`/users/${id}/status`, {method: 'POST', body: {status}}) + return coralApi(`/users/${id}/status`, {method: 'POST', body: {status}}) .then(() => { - dispatch({type: SET_COMMENTER_STATUS, id, status}); + return dispatch({type: SET_COMMENTER_STATUS, id, status}); }); }; diff --git a/client/coral-admin/src/actions/install.js b/client/coral-admin/src/actions/install.js index a575557d6..122ffdc4a 100644 --- a/client/coral-admin/src/actions/install.js +++ b/client/coral-admin/src/actions/install.js @@ -87,7 +87,7 @@ export const submitUser = () => (dispatch, getState) => { export const finishInstall = () => (dispatch, getState) => { const data = getState().install.toJS().data; dispatch(installRequest()); - coralApi('/setup', {method: 'POST', body: data}) + return coralApi('/setup', {method: 'POST', body: data}) .then(() => { dispatch(installSuccess()); dispatch(nextStep()); diff --git a/client/coral-admin/src/actions/users.js b/client/coral-admin/src/actions/users.js index 27f2cf34f..7ba051a90 100644 --- a/client/coral-admin/src/actions/users.js +++ b/client/coral-admin/src/actions/users.js @@ -9,7 +9,7 @@ import t from 'coral-framework/services/i18n'; export const userStatusUpdate = (status, userId, commentId) => { return (dispatch) => { dispatch({type: userTypes.UPDATE_STATUS_REQUEST}); - coralApi(`/users/${userId}/status`, {method: 'POST', body: {status: status, comment_id: commentId}}) + return coralApi(`/users/${userId}/status`, {method: 'POST', body: {status: status, comment_id: commentId}}) .then((res) => dispatch({type: userTypes.UPDATE_STATUS_SUCCESS, res})) .catch((error) => { console.error(error); @@ -22,7 +22,7 @@ export const userStatusUpdate = (status, userId, commentId) => { // change status of a user export const sendNotificationEmail = (userId, subject, body) => { return (dispatch) => { - coralApi(`/users/${userId}/email`, {method: 'POST', body: {subject, body}}) + return coralApi(`/users/${userId}/email`, {method: 'POST', body: {subject, body}}) .catch((error) => { console.error(error); const errorMessage = error.translation_key ? t(`error.${error.translation_key}`) : error.toString(); @@ -34,7 +34,7 @@ export const sendNotificationEmail = (userId, subject, body) => { // let a user edit their username export const enableUsernameEdit = (userId) => { return (dispatch) => { - coralApi(`/users/${userId}/username-enable`, {method: 'POST'}) + return coralApi(`/users/${userId}/username-enable`, {method: 'POST'}) .catch((error) => { console.error(error); const errorMessage = error.translation_key ? t(`error.${error.translation_key}`) : error.toString(); diff --git a/client/coral-framework/actions/auth.js b/client/coral-framework/actions/auth.js index 995b5db50..05e078010 100644 --- a/client/coral-framework/actions/auth.js +++ b/client/coral-framework/actions/auth.js @@ -133,7 +133,7 @@ export const fetchSignIn = (formData) => { return (dispatch) => { dispatch(signInRequest()); - coralApi('/auth/local', {method: 'POST', body: formData}) + return coralApi('/auth/local', {method: 'POST', body: formData}) .then(({token}) => { if (!bowser.safari && !bowser.ios) { dispatch(handleAuthToken(token)); @@ -360,7 +360,7 @@ const verifyEmailFailure = () => ({ export const requestConfirmEmail = (email) => (dispatch, getState) => { const redirectUri = getState().auth.toJS().redirectUri; dispatch(verifyEmailRequest()); - coralApi('/users/resend-verify', { + return coralApi('/users/resend-verify', { method: 'POST', body: {email}, headers: {'X-Pym-Url': redirectUri} diff --git a/client/coral-framework/actions/user.js b/client/coral-framework/actions/user.js index f18eb9151..a6ad45d4a 100644 --- a/client/coral-framework/actions/user.js +++ b/client/coral-framework/actions/user.js @@ -8,7 +8,7 @@ const editUsernameFailure = (error) => ({type: actions.EDIT_USERNAME_FAILURE, er const editUsernameSuccess = () => ({type: actions.EDIT_USERNAME_SUCCESS}); export const editName = (username) => (dispatch) => { - coralApi('/account/username', {method: 'PUT', body: {username}}) + return coralApi('/account/username', {method: 'PUT', body: {username}}) .then(() => { dispatch(editUsernameSuccess()); dispatch(addNotification('success', t('framework.success_name_update')));