pleroma/app/soapbox/actions/instance.js

30 lines
599 B
JavaScript
Raw Normal View History

2020-04-01 13:05:52 -07:00
import api from '../api';
export const INSTANCE_IMPORT = 'INSTANCE_IMPORT';
export const INSTANCE_FAIL = 'INSTANCE_FAIL';
export function fetchInstance() {
return (dispatch, getState) => {
2020-04-14 11:44:40 -07:00
api(getState).get('/api/v1/instance').then(response => {
2020-04-01 13:05:52 -07:00
dispatch(importInstance(response.data));
}).catch(error => {
dispatch(instanceFail(error));
});
};
}
export function importInstance(instance) {
return {
type: INSTANCE_IMPORT,
2020-04-14 11:44:40 -07:00
instance,
2020-04-01 13:05:52 -07:00
};
}
export function instanceFail(error) {
return {
type: INSTANCE_FAIL,
error,
skipAlert: true,
};
};