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.
42 lines
1006 B
42 lines
1006 B
import $ from 'jquery';
|
|
import updateEpisodes from 'Utilities/Episode/updateEpisodes';
|
|
|
|
function createBatchToggleEpisodeMonitoredHandler(section, getFromState) {
|
|
return function(payload) {
|
|
return function(dispatch, getState) {
|
|
const {
|
|
albumIds,
|
|
monitored
|
|
} = payload;
|
|
|
|
const state = getFromState(getState());
|
|
|
|
updateEpisodes(dispatch, section, state.items, albumIds, {
|
|
isSaving: true
|
|
});
|
|
|
|
const promise = $.ajax({
|
|
url: '/episode/monitor',
|
|
method: 'PUT',
|
|
data: JSON.stringify({ albumIds, monitored }),
|
|
dataType: 'json'
|
|
});
|
|
|
|
promise.done(() => {
|
|
updateEpisodes(dispatch, section, state.items, albumIds, {
|
|
isSaving: false,
|
|
monitored
|
|
});
|
|
});
|
|
|
|
promise.fail(() => {
|
|
updateEpisodes(dispatch, section, state.items, albumIds, {
|
|
isSaving: false
|
|
});
|
|
});
|
|
};
|
|
};
|
|
}
|
|
|
|
export default createBatchToggleEpisodeMonitoredHandler;
|