Fixed: Batch Monitor/Unmonitor on Wanted Pages

This commit is contained in:
Qstick
2017-10-28 21:44:06 -04:00
parent b99b23b4bb
commit 9f079fb8ba
12 changed files with 43 additions and 43 deletions
@@ -0,0 +1,41 @@
import $ from 'jquery';
import updateAlbums from 'Utilities/Album/updateAlbums';
function createBatchToggleAlbumMonitoredHandler(section, getFromState) {
return function(payload) {
return function(dispatch, getState) {
const {
albumIds,
monitored
} = payload;
const state = getFromState(getState());
updateAlbums(dispatch, section, state.items, albumIds, {
isSaving: true
});
const promise = $.ajax({
url: '/album/monitor',
method: 'PUT',
data: JSON.stringify({ albumIds, monitored }),
dataType: 'json'
});
promise.done(() => {
updateAlbums(dispatch, section, state.items, albumIds, {
isSaving: false,
monitored
});
});
promise.fail(() => {
updateAlbums(dispatch, section, state.items, albumIds, {
isSaving: false
});
});
};
};
}
export default createBatchToggleAlbumMonitoredHandler;