mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-07 21:42:16 -07:00
33 lines
689 B
JavaScript
33 lines
689 B
JavaScript
import $ from 'jquery';
|
|
import { set } from '../baseActions';
|
|
|
|
function createFetchSchemaHandler(section, url) {
|
|
return function(getState, payload, dispatch) {
|
|
dispatch(set({ section, isFetchingSchema: true }));
|
|
|
|
const promise = $.ajax({
|
|
url
|
|
});
|
|
|
|
promise.done((data) => {
|
|
dispatch(set({
|
|
section,
|
|
isFetchingSchema: false,
|
|
schemaPopulated: true,
|
|
schemaError: null,
|
|
schema: data
|
|
}));
|
|
});
|
|
|
|
promise.fail((xhr) => {
|
|
dispatch(set({
|
|
section,
|
|
isFetchingSchema: false,
|
|
schemaPopulated: true,
|
|
schemaError: xhr
|
|
}));
|
|
});
|
|
};
|
|
}
|
|
|
|
export default createFetchSchemaHandler;
|