[UI] Fix Album History Showing for Every Album

This commit is contained in:
Qstick 2017-09-17 21:26:38 -04:00
parent 6e7299cdf2
commit 9f689c0233
12 changed files with 103 additions and 103 deletions

View file

@ -96,9 +96,9 @@ export const UPDATE_EPISODE_FILES = 'UPDATE_EPISODE_FILES';
//
// Episode History
export const FETCH_EPISODE_HISTORY = 'FETCH_EPISODE_HISTORY';
export const CLEAR_EPISODE_HISTORY = 'CLEAR_EPISODE_HISTORY';
export const EPISODE_HISTORY_MARK_AS_FAILED = 'EPISODE_HISTORY_MARK_AS_FAILED';
export const FETCH_ALBUM_HISTORY = 'FETCH_ALBUM_HISTORY';
export const CLEAR_ALBUM_HISTORY = 'CLEAR_ALBUM_HISTORY';
export const ALBUM_HISTORY_MARK_AS_FAILED = 'ALBUM_HISTORY_MARK_AS_FAILED';
//
// Releases

View file

@ -3,11 +3,11 @@ import { batchActions } from 'redux-batched-actions';
import { sortDirections } from 'Helpers/Props';
import * as types from './actionTypes';
import { set, update } from './baseActions';
import { fetchEpisodeHistory } from './episodeHistoryActions';
import { fetchAlbumHistory } from './albumHistoryActions';
const episodeHistoryActionHandlers = {
[types.FETCH_EPISODE_HISTORY]: function(payload) {
const section = 'episodeHistory';
const albumHistoryActionHandlers = {
[types.FETCH_ALBUM_HISTORY]: function(payload) {
const section = 'albumHistory';
return function(dispatch, getState) {
dispatch(set({ section, isFetching: true }));
@ -15,8 +15,8 @@ const episodeHistoryActionHandlers = {
const queryParams = {
pageSize: 1000,
page: 1,
filterKey: 'episodeId',
filterValue: payload.episodeId,
filterKey: 'albumId',
filterValue: payload.albumId,
sortKey: 'date',
sortDirection: sortDirections.DESCENDING
};
@ -50,11 +50,11 @@ const episodeHistoryActionHandlers = {
};
},
[types.EPISODE_HISTORY_MARK_AS_FAILED]: function(payload) {
[types.ALBUM_HISTORY_MARK_AS_FAILED]: function(payload) {
return function(dispatch, getState) {
const {
historyId,
episodeId
albumId
} = payload;
const promise = $.ajax({
@ -66,10 +66,10 @@ const episodeHistoryActionHandlers = {
});
promise.done(() => {
dispatch(fetchEpisodeHistory({ episodeId }));
dispatch(fetchAlbumHistory({ albumId }));
});
};
}
};
export default episodeHistoryActionHandlers;
export default albumHistoryActionHandlers;

View file

@ -0,0 +1,7 @@
import { createAction } from 'redux-actions';
import * as types from './actionTypes';
import albumHistoryActionHandlers from './albumHistoryActionHandlers';
export const fetchAlbumHistory = albumHistoryActionHandlers[types.FETCH_ALBUM_HISTORY];
export const clearAlbumHistory = createAction(types.CLEAR_ALBUM_HISTORY);
export const albumHistoryMarkAsFailed = albumHistoryActionHandlers[types.ALBUM_HISTORY_MARK_AS_FAILED];

View file

@ -1,7 +0,0 @@
import { createAction } from 'redux-actions';
import * as types from './actionTypes';
import episodeHistoryActionHandlers from './episodeHistoryActionHandlers';
export const fetchEpisodeHistory = episodeHistoryActionHandlers[types.FETCH_EPISODE_HISTORY];
export const clearEpisodeHistory = createAction(types.CLEAR_EPISODE_HISTORY);
export const episodeHistoryMarkAsFailed = episodeHistoryActionHandlers[types.EPISODE_HISTORY_MARK_AS_FAILED];