mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-12 16:13:58 -07:00
Initial Commit Rework
This commit is contained in:
parent
74a4cc048c
commit
95051cbd63
2483 changed files with 101351 additions and 111396 deletions
59
frontend/src/Store/Actions/rootFolderActionHandlers.js
Normal file
59
frontend/src/Store/Actions/rootFolderActionHandlers.js
Normal file
|
@ -0,0 +1,59 @@
|
|||
import $ from 'jquery';
|
||||
import { batchActions } from 'redux-batched-actions';
|
||||
import * as types from './actionTypes';
|
||||
import createFetchHandler from './Creators/createFetchHandler';
|
||||
import createRemoveItemHandler from './Creators/createRemoveItemHandler';
|
||||
import { set, updateItem } from './baseActions';
|
||||
|
||||
const section = 'rootFolders';
|
||||
|
||||
const rootFolderActionHandlers = {
|
||||
[types.FETCH_ROOT_FOLDERS]: createFetchHandler('rootFolders', '/rootFolder'),
|
||||
|
||||
[types.DELETE_ROOT_FOLDER]: createRemoveItemHandler('rootFolders',
|
||||
'/rootFolder',
|
||||
(state) => state.rootFolders),
|
||||
|
||||
[types.ADD_ROOT_FOLDER]: function(payload) {
|
||||
return function(dispatch, getState) {
|
||||
const path = payload.path;
|
||||
|
||||
dispatch(set({
|
||||
section,
|
||||
isSaving: true
|
||||
}));
|
||||
|
||||
const promise = $.ajax({
|
||||
url: '/rootFolder',
|
||||
method: 'POST',
|
||||
data: JSON.stringify({ path }),
|
||||
dataType: 'json'
|
||||
});
|
||||
|
||||
promise.done((data) => {
|
||||
dispatch(batchActions([
|
||||
updateItem({
|
||||
section,
|
||||
...data
|
||||
}),
|
||||
|
||||
set({
|
||||
section,
|
||||
isSaving: false,
|
||||
saveError: null
|
||||
})
|
||||
]));
|
||||
});
|
||||
|
||||
promise.fail((xhr) => {
|
||||
dispatch(set({
|
||||
section,
|
||||
isSaving: false,
|
||||
saveError: xhr
|
||||
}));
|
||||
});
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
export default rootFolderActionHandlers;
|
Loading…
Add table
Add a link
Reference in a new issue