mirror of
https://github.com/wassname/talk.git
synced 2026-07-13 11:29:55 +08:00
Return the returns
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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')));
|
||||
|
||||
Reference in New Issue
Block a user