gab-social/app/javascript/gabsocial/actions/status_revisions.js

31 lines
874 B
JavaScript
Raw Normal View History

2020-03-27 22:57:03 +00:00
import api from '../api'
2020-11-25 21:22:37 +00:00
export const STATUS_REVISIONS_LOAD_REQUEST = 'STATUS_REVISIONS_LOAD_REQUEST'
2020-03-27 22:57:03 +00:00
export const STATUS_REVISIONS_LOAD_SUCCESS = 'STATUS_REVISIONS_SUCCESS'
export const STATUS_REVISIONS_LOAD_FAIL = 'STATUS_REVISIONS_FAIL'
2020-11-25 21:22:37 +00:00
/**
*
*/
2020-11-15 18:48:32 +00:00
export const loadStatusRevisions = (statusId) => (dispatch, getState) => {
2020-11-25 21:22:37 +00:00
dispatch(loadStatusRevisionsRequest())
2020-11-15 18:48:32 +00:00
api(getState).get(`/api/v1/statuses/${statusId}/revisions`)
.then(res => dispatch(loadStatusRevisionsSuccess(res.data)))
.catch((error) => dispatch(loadStatusRevisionsFail(error)))
2020-11-15 18:48:32 +00:00
}
2020-11-25 21:22:37 +00:00
const loadStatusRevisionsRequest = () => ({
type: STATUS_REVISIONS_LOAD_REQUEST,
})
2020-03-27 22:57:03 +00:00
const loadStatusRevisionsSuccess = (data) => ({
type: STATUS_REVISIONS_LOAD_SUCCESS,
revisions: data,
})
const loadStatusRevisionsFail = (error) => ({
2020-03-27 22:57:03 +00:00
type: STATUS_REVISIONS_LOAD_FAIL,
showToast: true,
error,
})