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.
43 lines
1.0 KiB
43 lines
1.0 KiB
import $ from 'jquery';
|
|
import updateAlbums from 'Utilities/Album/updateAlbums';
|
|
import getSectionState from 'Utilities/State/getSectionState';
|
|
|
|
function createToggleAlbumMonitoredHandler(section) {
|
|
return function(payload) {
|
|
return function(dispatch, getState) {
|
|
const {
|
|
albumId,
|
|
monitored
|
|
} = payload;
|
|
|
|
const state = getSectionState(getState(), section, true);
|
|
|
|
updateAlbums(dispatch, section, state.items, [albumId], {
|
|
isSaving: true
|
|
});
|
|
|
|
const promise = $.ajax({
|
|
url: `/album/${albumId}`,
|
|
method: 'PUT',
|
|
data: JSON.stringify({ monitored }),
|
|
dataType: 'json'
|
|
});
|
|
|
|
promise.done(() => {
|
|
updateAlbums(dispatch, section, state.items, [albumId], {
|
|
isSaving: false,
|
|
monitored
|
|
});
|
|
});
|
|
|
|
promise.fail(() => {
|
|
updateAlbums(dispatch, section, state.items, [albumId], {
|
|
isSaving: false
|
|
});
|
|
});
|
|
};
|
|
};
|
|
}
|
|
|
|
export default createToggleAlbumMonitoredHandler;
|