mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-23 22:45:06 -04:00
34 lines
749 B
JavaScript
34 lines
749 B
JavaScript
import createAjaxRequest from 'Utilities/createAjaxRequest';
|
|
import { set } from '../baseActions';
|
|
|
|
function createFetchSchemaHandler(section, url) {
|
|
return function(getState, payload, dispatch) {
|
|
dispatch(set({ section, isSchemaFetching: true }));
|
|
|
|
const promise = createAjaxRequest({
|
|
url
|
|
}).request;
|
|
|
|
promise.done((data) => {
|
|
dispatch(set({
|
|
section,
|
|
isSchemaFetching: false,
|
|
isSchemaPopulated: true,
|
|
schemaError: null,
|
|
schema: data
|
|
}));
|
|
});
|
|
|
|
promise.fail((xhr) => {
|
|
dispatch(set({
|
|
section,
|
|
isSchemaFetching: false,
|
|
isSchemaPopulated: true,
|
|
schemaError: xhr
|
|
}));
|
|
});
|
|
};
|
|
}
|
|
|
|
export default createFetchSchemaHandler;
|