New: Artist History Modal in Artist Details Page

This commit is contained in:
Qstick 2017-12-13 22:38:27 -05:00
parent 0981260887
commit 7e4a8c8ff7
17 changed files with 659 additions and 96 deletions

View file

@ -0,0 +1,104 @@
import $ from 'jquery';
import { createAction } from 'redux-actions';
import { batchActions } from 'redux-batched-actions';
import { createThunk, handleThunks } from 'Store/thunks';
import createHandleActions from './Creators/createHandleActions';
import { set, update } from './baseActions';
//
// Variables
export const section = 'artistHistory';
//
// State
export const defaultState = {
isFetching: false,
isPopulated: false,
error: null,
items: []
};
//
// Actions Types
export const FETCH_ARTIST_HISTORY = 'artistHistory/fetchArtistHistory';
export const CLEAR_ARTIST_HISTORY = 'artistHistory/clearArtistHistory';
export const ARTIST_HISTORY_MARK_AS_FAILED = 'artistHistory/artistHistoryMarkAsFailed';
//
// Action Creators
export const fetchArtistHistory = createThunk(FETCH_ARTIST_HISTORY);
export const clearArtistHistory = createAction(CLEAR_ARTIST_HISTORY);
export const artistHistoryMarkAsFailed = createThunk(ARTIST_HISTORY_MARK_AS_FAILED);
//
// Action Handlers
export const actionHandlers = handleThunks({
[FETCH_ARTIST_HISTORY]: function(getState, payload, dispatch) {
dispatch(set({ section, isFetching: true }));
const promise = $.ajax({
url: '/history/artist',
data: payload
});
promise.done((data) => {
dispatch(batchActions([
update({ section, data }),
set({
section,
isFetching: false,
isPopulated: true,
error: null
})
]));
});
promise.fail((xhr) => {
dispatch(set({
section,
isFetching: false,
isPopulated: false,
error: xhr
}));
});
},
[ARTIST_HISTORY_MARK_AS_FAILED]: function(getState, payload, dispatch) {
const {
historyId,
artistId,
albumId
} = payload;
const promise = $.ajax({
url: '/history/failed',
method: 'POST',
data: {
id: historyId
}
});
promise.done(() => {
dispatch(fetchArtistHistory({ artistId, albumId }));
});
}
});
//
// Reducers
export const reducers = createHandleActions({
[CLEAR_ARTIST_HISTORY]: (state) => {
return Object.assign({}, state, defaultState);
}
}, defaultState, section);

View file

@ -19,6 +19,7 @@ import * as rootFolders from './rootFolderActions';
import * as albumStudio from './albumStudioActions';
import * as artist from './artistActions';
import * as artistEditor from './artistEditorActions';
import * as artistHistory from './artistHistoryActions';
import * as artistIndex from './artistIndexActions';
import * as settings from './settingsActions';
import * as system from './systemActions';
@ -48,6 +49,7 @@ export default [
albumStudio,
artist,
artistEditor,
artistHistory,
artistIndex,
settings,
system,

View file

@ -31,6 +31,12 @@ export const defaultState = {
recentFolders: [],
importMode: 'move',
sortPredicates: {
relativePath: function(item, direction) {
const relativePath = item.relativePath;
return relativePath.toLowerCase();
},
artist: function(item, direction) {
const artist = item.artist;