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

View file

@ -1,7 +1,7 @@
import $ from 'jquery';
import updateEpisodes from 'Utilities/Episode/updateEpisodes';
import updateAlbums from 'Utilities/Album/updateAlbums';
function createBatchToggleEpisodeMonitoredHandler(section, getFromState) {
function createBatchToggleAlbumMonitoredHandler(section, getFromState) {
return function(payload) {
return function(dispatch, getState) {
const {
@ -11,26 +11,26 @@ function createBatchToggleEpisodeMonitoredHandler(section, getFromState) {
const state = getFromState(getState());
updateEpisodes(dispatch, section, state.items, albumIds, {
updateAlbums(dispatch, section, state.items, albumIds, {
isSaving: true
});
const promise = $.ajax({
url: '/episode/monitor',
url: '/album/monitor',
method: 'PUT',
data: JSON.stringify({ albumIds, monitored }),
dataType: 'json'
});
promise.done(() => {
updateEpisodes(dispatch, section, state.items, albumIds, {
updateAlbums(dispatch, section, state.items, albumIds, {
isSaving: false,
monitored
});
});
promise.fail(() => {
updateEpisodes(dispatch, section, state.items, albumIds, {
updateAlbums(dispatch, section, state.items, albumIds, {
isSaving: false
});
});
@ -38,4 +38,4 @@ function createBatchToggleEpisodeMonitoredHandler(section, getFromState) {
};
}
export default createBatchToggleEpisodeMonitoredHandler;
export default createBatchToggleAlbumMonitoredHandler;

View file

@ -1,7 +1,7 @@
import $ from 'jquery';
import updateEpisodes from 'Utilities/Episode/updateEpisodes';
import updateAlbums from 'Utilities/Album/updateAlbums';
function createToggleEpisodeMonitoredHandler(section, getFromState) {
function createToggleAlbumMonitoredHandler(section, getFromState) {
return function(payload) {
return function(dispatch, getState) {
const {
@ -11,26 +11,26 @@ function createToggleEpisodeMonitoredHandler(section, getFromState) {
const state = getFromState(getState());
updateEpisodes(dispatch, section, state.items, [albumId], {
updateAlbums(dispatch, section, state.items, [albumId], {
isSaving: true
});
const promise = $.ajax({
url: `/episode/${albumId}`,
url: `/album/${albumId}`,
method: 'PUT',
data: JSON.stringify({ monitored }),
dataType: 'json'
});
promise.done(() => {
updateEpisodes(dispatch, section, state.items, [albumId], {
updateAlbums(dispatch, section, state.items, [albumId], {
isSaving: false,
monitored
});
});
promise.fail(() => {
updateEpisodes(dispatch, section, state.items, [albumId], {
updateAlbums(dispatch, section, state.items, [albumId], {
isSaving: false
});
});
@ -38,4 +38,4 @@ function createToggleEpisodeMonitoredHandler(section, getFromState) {
};
}
export default createToggleEpisodeMonitoredHandler;
export default createToggleAlbumMonitoredHandler;

View file

@ -103,7 +103,7 @@ export const DELETE_TRACK_FILES = 'DELETE_TRACK_FILES';
export const UPDATE_TRACK_FILES = 'UPDATE_TRACK_FILES';
//
// Episode History
// Album History
export const FETCH_ALBUM_HISTORY = 'FETCH_ALBUM_HISTORY';
export const CLEAR_ALBUM_HISTORY = 'CLEAR_ALBUM_HISTORY';
@ -195,7 +195,7 @@ export const SET_MISSING_FILTER = 'SET_MISSING_FILTER';
export const SET_MISSING_TABLE_OPTION = 'SET_MISSING_TABLE_OPTION';
export const CLEAR_MISSING = 'CLEAR_MISSING';
export const BATCH_TOGGLE_MISSING_EPISODES = 'BATCH_TOGGLE_MISSING_EPISODES';
export const BATCH_TOGGLE_MISSING_ALBUMS = 'BATCH_TOGGLE_MISSING_ALBUMS';
export const FETCH_CUTOFF_UNMET = 'FETCH_CUTOFF_UNMET';
export const GOTO_FIRST_CUTOFF_UNMET_PAGE = 'GOTO_FIRST_CUTOFF_UNMET_PAGE';
@ -208,7 +208,7 @@ export const SET_CUTOFF_UNMET_FILTER = 'SET_CUTOFF_UNMET_FILTER';
export const SET_CUTOFF_UNMET_TABLE_OPTION = 'SET_CUTOFF_UNMET_TABLE_OPTION';
export const CLEAR_CUTOFF_UNMET = 'CLEAR_CUTOFF_UNMET';
export const BATCH_TOGGLE_CUTOFF_UNMET_EPISODES = 'BATCH_TOGGLE_CUTOFF_UNMET_EPISODES';
export const BATCH_TOGGLE_CUTOFF_UNMET_ALBUMS = 'BATCH_TOGGLE_CUTOFF_UNMET_ALBUMS';
//
// Settings

View file

@ -1,5 +1,5 @@
import serverSideCollectionHandlers from 'Utilities/serverSideCollectionHandlers';
import createBatchToggleEpisodeMonitoredHandler from './Creators/createBatchToggleEpisodeMonitoredHandler';
import createBatchToggleAlbumMonitoredHandler from './Creators/createBatchToggleAlbumMonitoredHandler';
import createServerSideCollectionHandlers from './Creators/createServerSideCollectionHandlers';
import * as types from './actionTypes';
@ -15,7 +15,7 @@ const wantedActionHandlers = {
[serverSideCollectionHandlers.FILTER]: types.SET_MISSING_FILTER
}),
[types.BATCH_TOGGLE_MISSING_EPISODES]: createBatchToggleEpisodeMonitoredHandler('missing', (state) => state.wanted.missing),
[types.BATCH_TOGGLE_MISSING_ALBUMS]: createBatchToggleAlbumMonitoredHandler('missing', (state) => state.wanted.missing),
...createServerSideCollectionHandlers('cutoffUnmet', '/wanted/cutoff', (state) => state.wanted, {
[serverSideCollectionHandlers.FETCH]: types.FETCH_CUTOFF_UNMET,
@ -28,7 +28,7 @@ const wantedActionHandlers = {
[serverSideCollectionHandlers.FILTER]: types.SET_CUTOFF_UNMET_FILTER
}),
[types.BATCH_TOGGLE_CUTOFF_UNMET_EPISODES]: createBatchToggleEpisodeMonitoredHandler('cutoffUnmet', (state) => state.wanted.cutoffUnmet)
[types.BATCH_TOGGLE_CUTOFF_UNMET_ALBUMS]: createBatchToggleAlbumMonitoredHandler('cutoffUnmet', (state) => state.wanted.cutoffUnmet)
};
export default wantedActionHandlers;

View file

@ -16,7 +16,7 @@ export const setMissingFilter = wantedActionHandlers[types.SET_MISSING_FILTER];
export const setMissingTableOption = createAction(types.SET_MISSING_TABLE_OPTION);
export const clearMissing = createAction(types.CLEAR_MISSING);
export const batchToggleMissingEpisodes = wantedActionHandlers[types.BATCH_TOGGLE_MISSING_EPISODES];
export const batchToggleMissingAlbums = wantedActionHandlers[types.BATCH_TOGGLE_MISSING_ALBUMS];
//
// Cutoff Unmet
@ -32,4 +32,4 @@ export const setCutoffUnmetFilter = wantedActionHandlers[types.SET_CUTOFF_UNMET_
export const setCutoffUnmetTableOption= createAction(types.SET_CUTOFF_UNMET_TABLE_OPTION);
export const clearCutoffUnmet= createAction(types.CLEAR_CUTOFF_UNMET);
export const batchToggleCutoffUnmetEpisodes = wantedActionHandlers[types.BATCH_TOGGLE_CUTOFF_UNMET_EPISODES];
export const batchToggleCutoffUnmetAlbums = wantedActionHandlers[types.BATCH_TOGGLE_CUTOFF_UNMET_ALBUMS];