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

30 lines
826 B
JavaScript
Raw Normal View History

2020-11-15 18:48:32 +00:00
import api from '../api'
2019-07-02 08:10:25 +01:00
2020-11-15 18:48:32 +00:00
export const CUSTOM_EMOJIS_FETCH_REQUEST = 'CUSTOM_EMOJIS_FETCH_REQUEST'
export const CUSTOM_EMOJIS_FETCH_SUCCESS = 'CUSTOM_EMOJIS_FETCH_SUCCESS'
export const CUSTOM_EMOJIS_FETCH_FAIL = 'CUSTOM_EMOJIS_FETCH_FAIL'
2019-07-02 08:10:25 +01:00
2020-11-15 18:48:32 +00:00
export const fetchCustomEmojis = () => (dispatch, getState) => {
dispatch(fetchCustomEmojisRequest())
2019-07-02 08:10:25 +01:00
2020-11-15 18:48:32 +00:00
api(getState).get('/api/v1/custom_emojis').then((response) => {
dispatch(fetchCustomEmojisSuccess(response.data))
}).catch((error) => {
dispatch(fetchCustomEmojisFail(error))
})
}
2019-07-02 08:10:25 +01:00
2020-11-15 18:48:32 +00:00
const fetchCustomEmojisRequest = () => ({
type: CUSTOM_EMOJIS_FETCH_REQUEST,
})
2019-07-02 08:10:25 +01:00
2020-11-15 18:48:32 +00:00
const fetchCustomEmojisSuccess = (custom_emojis) => ({
type: CUSTOM_EMOJIS_FETCH_SUCCESS,
custom_emojis,
})
2019-07-02 08:10:25 +01:00
2020-11-15 18:48:32 +00:00
const fetchCustomEmojisFail = (error) => ({
type: CUSTOM_EMOJIS_FETCH_FAIL,
error,
})