You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Lidarr/frontend/src/Store/Actions/Creators/createBatchToggleAlbumMonit...

43 lines
1023 B

import $ from 'jquery';
import updateAlbums from 'Utilities/Album/updateAlbums';
import getSectionState from 'Utilities/State/getSectionState';
function createBatchToggleAlbumMonitoredHandler(section, fetchHandler) {
return function(getState, payload, dispatch) {
const {
albumIds,
monitored
} = payload;
const state = getSectionState(getState(), section, true);
dispatch(updateAlbums(section, state.items, albumIds, {
isSaving: true
}));
const promise = $.ajax({
url: '/album/monitor',
method: 'PUT',
data: JSON.stringify({ albumIds, monitored }),
dataType: 'json'
});
promise.done(() => {
dispatch(updateAlbums(section, state.items, albumIds, {
isSaving: false,
monitored
}));
dispatch(fetchHandler());
});
promise.fail(() => {
dispatch(updateAlbums(section, state.items, albumIds, {
isSaving: false
}));
});
};
}
export default createBatchToggleAlbumMonitoredHandler;