mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-23 22:25:09 -04:00
Renames in Frontend
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import _ from 'lodash';
|
||||
import { createAction } from 'redux-actions';
|
||||
import { batchActions } from 'redux-batched-actions';
|
||||
import monitorOptions from 'Utilities/Artist/monitorOptions';
|
||||
import monitorOptions from 'Utilities/Author/monitorOptions';
|
||||
import getSectionState from 'Utilities/State/getSectionState';
|
||||
import updateSectionState from 'Utilities/State/updateSectionState';
|
||||
import createAjaxRequest from 'Utilities/createAjaxRequest';
|
||||
import getNewArtist from 'Utilities/Artist/getNewArtist';
|
||||
import getNewAlbum from 'Utilities/Album/getNewAlbum';
|
||||
import getNewAuthor from 'Utilities/Author/getNewAuthor';
|
||||
import getNewBook from 'Utilities/Book/getNewBook';
|
||||
import { createThunk, handleThunks } from 'Store/thunks';
|
||||
import createHandleActions from './Creators/createHandleActions';
|
||||
import { set, update, updateItem } from './baseActions';
|
||||
@@ -46,8 +46,8 @@ export const persistState = [
|
||||
// Actions Types
|
||||
|
||||
export const GET_SEARCH_RESULTS = 'search/getSearchResults';
|
||||
export const ADD_ARTIST = 'search/addArtist';
|
||||
export const ADD_ALBUM = 'search/addAlbum';
|
||||
export const ADD_AUTHOR = 'search/addAuthor';
|
||||
export const ADD_BOOK = 'search/addBook';
|
||||
export const CLEAR_SEARCH_RESULTS = 'search/clearSearchResults';
|
||||
export const SET_ADD_DEFAULT = 'search/setAddDefault';
|
||||
|
||||
@@ -55,8 +55,8 @@ export const SET_ADD_DEFAULT = 'search/setAddDefault';
|
||||
// Action Creators
|
||||
|
||||
export const getSearchResults = createThunk(GET_SEARCH_RESULTS);
|
||||
export const addArtist = createThunk(ADD_ARTIST);
|
||||
export const addAlbum = createThunk(ADD_ALBUM);
|
||||
export const addAuthor = createThunk(ADD_AUTHOR);
|
||||
export const addBook = createThunk(ADD_BOOK);
|
||||
export const clearSearchResults = createAction(CLEAR_SEARCH_RESULTS);
|
||||
export const setAddDefault = createAction(SET_ADD_DEFAULT);
|
||||
|
||||
@@ -104,24 +104,24 @@ export const actionHandlers = handleThunks({
|
||||
});
|
||||
},
|
||||
|
||||
[ADD_ARTIST]: function(getState, payload, dispatch) {
|
||||
[ADD_AUTHOR]: function(getState, payload, dispatch) {
|
||||
dispatch(set({ section, isAdding: true }));
|
||||
|
||||
const foreignAuthorId = payload.foreignAuthorId;
|
||||
const items = getState().search.items;
|
||||
const itemToAdd = _.find(items, { foreignId: foreignAuthorId });
|
||||
const newArtist = getNewArtist(_.cloneDeep(itemToAdd.artist), payload);
|
||||
const newAuthor = getNewAuthor(_.cloneDeep(itemToAdd.author), payload);
|
||||
|
||||
const promise = createAjaxRequest({
|
||||
url: '/artist',
|
||||
url: '/author',
|
||||
method: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(newArtist)
|
||||
data: JSON.stringify(newAuthor)
|
||||
}).request;
|
||||
|
||||
promise.done((data) => {
|
||||
dispatch(batchActions([
|
||||
updateItem({ section: 'artist', ...data }),
|
||||
updateItem({ section: 'authors', ...data }),
|
||||
|
||||
set({
|
||||
section,
|
||||
@@ -142,26 +142,26 @@ export const actionHandlers = handleThunks({
|
||||
});
|
||||
},
|
||||
|
||||
[ADD_ALBUM]: function(getState, payload, dispatch) {
|
||||
[ADD_BOOK]: function(getState, payload, dispatch) {
|
||||
dispatch(set({ section, isAdding: true }));
|
||||
|
||||
const foreignBookId = payload.foreignBookId;
|
||||
const items = getState().search.items;
|
||||
const itemToAdd = _.find(items, { foreignId: foreignBookId });
|
||||
const newAlbum = getNewAlbum(_.cloneDeep(itemToAdd.album), payload);
|
||||
const newBook = getNewBook(_.cloneDeep(itemToAdd.book), payload);
|
||||
|
||||
const promise = createAjaxRequest({
|
||||
url: '/album',
|
||||
url: '/book',
|
||||
method: 'POST',
|
||||
contentType: 'application/json',
|
||||
data: JSON.stringify(newAlbum)
|
||||
data: JSON.stringify(newBook)
|
||||
}).request;
|
||||
|
||||
promise.done((data) => {
|
||||
data.releases = itemToAdd.album.releases;
|
||||
itemToAdd.album = data;
|
||||
data.releases = itemToAdd.book.releases;
|
||||
itemToAdd.book = data;
|
||||
dispatch(batchActions([
|
||||
updateItem({ section: 'artist', ...data.artist }),
|
||||
updateItem({ section: 'authors', ...data.author }),
|
||||
updateItem({ section, ...itemToAdd }),
|
||||
|
||||
set({
|
||||
|
||||
Reference in New Issue
Block a user