Fix GitIgnore, Update from Sonarr

This commit is contained in:
Qstick
2017-09-10 21:20:36 -04:00
parent 77f1d2e64c
commit 22d9c5e666
17 changed files with 603 additions and 51 deletions
@@ -1,8 +1,19 @@
import $ from 'jquery';
import { batchActions } from 'redux-batched-actions';
import createAjaxRequest from 'Utilities/createAjaxRequest';
import getProviderState from 'Utilities/State/getProviderState';
import { set, updateItem } from '../baseActions';
const abortCurrentRequests = {};
export function createCancelSaveProviderHandler(section) {
return function(payload) {
if (abortCurrentRequests[section]) {
abortCurrentRequests[section]();
abortCurrentRequests[section] = null;
}
};
}
function createSaveProviderHandler(section, url, getFromState) {
return function(payload) {
return function(dispatch, getState) {
@@ -24,9 +35,11 @@ function createSaveProviderHandler(section, url, getFromState) {
ajaxOptions.method = 'PUT';
}
const promise = $.ajax(ajaxOptions);
const { request, abortRequest } = createAjaxRequest()(ajaxOptions);
promise.done((data) => {
abortCurrentRequests[section] = abortRequest;
request.done((data) => {
dispatch(batchActions([
updateItem({ section, ...data }),
@@ -39,11 +52,11 @@ function createSaveProviderHandler(section, url, getFromState) {
]));
});
promise.fail((xhr) => {
request.fail((xhr) => {
dispatch(set({
section,
isSaving: false,
saveError: xhr
saveError: xhr.aborted ? null : xhr
}));
});
};