soapbox/app/soapbox/actions/custom_emojis.js

44 lines
1.0 KiB
JavaScript
Raw Normal View History

2020-03-27 15:59:38 -05:00
import api from '../api';
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';
export function fetchCustomEmojis() {
return (dispatch, getState) => {
2022-05-14 14:33:14 -04:00
const me = getState().get('me');
if (!me) return;
2020-03-27 15:59:38 -05:00
dispatch(fetchCustomEmojisRequest());
api(getState).get('/api/v1/custom_emojis').then(response => {
dispatch(fetchCustomEmojisSuccess(response.data));
}).catch(error => {
dispatch(fetchCustomEmojisFail(error));
});
};
2021-08-03 14:22:51 -05:00
}
2020-03-27 15:59:38 -05:00
export function fetchCustomEmojisRequest() {
return {
type: CUSTOM_EMOJIS_FETCH_REQUEST,
skipLoading: true,
};
2021-08-03 14:22:51 -05:00
}
2020-03-27 15:59:38 -05:00
export function fetchCustomEmojisSuccess(custom_emojis) {
return {
type: CUSTOM_EMOJIS_FETCH_SUCCESS,
custom_emojis,
skipLoading: true,
};
2021-08-03 14:22:51 -05:00
}
2020-03-27 15:59:38 -05:00
export function fetchCustomEmojisFail(error) {
return {
type: CUSTOM_EMOJIS_FETCH_FAIL,
error,
skipLoading: true,
};
2021-08-03 14:22:51 -05:00
}