|
|
@ -88,6 +88,8 @@ export const actionHandlers = handleThunks({
|
|
|
|
abortCurrentRequest = abortRequest;
|
|
|
|
abortCurrentRequest = abortRequest;
|
|
|
|
|
|
|
|
|
|
|
|
request.done((data) => {
|
|
|
|
request.done((data) => {
|
|
|
|
|
|
|
|
data = data.map((movie) => ({ ...movie, internalId: movie.id, id: movie.tmdbId }));
|
|
|
|
|
|
|
|
|
|
|
|
dispatch(batchActions([
|
|
|
|
dispatch(batchActions([
|
|
|
|
update({ section, data }),
|
|
|
|
update({ section, data }),
|
|
|
|
|
|
|
|
|
|
|
@ -116,6 +118,7 @@ export const actionHandlers = handleThunks({
|
|
|
|
const tmdbId = payload.tmdbId;
|
|
|
|
const tmdbId = payload.tmdbId;
|
|
|
|
const items = getState().addMovie.items;
|
|
|
|
const items = getState().addMovie.items;
|
|
|
|
const newMovie = getNewMovie(_.cloneDeep(_.find(items, { tmdbId })), payload);
|
|
|
|
const newMovie = getNewMovie(_.cloneDeep(_.find(items, { tmdbId })), payload);
|
|
|
|
|
|
|
|
newMovie.id = 0;
|
|
|
|
|
|
|
|
|
|
|
|
const promise = createAjaxRequest({
|
|
|
|
const promise = createAjaxRequest({
|
|
|
|
url: '/movie',
|
|
|
|
url: '/movie',
|
|
|
@ -125,8 +128,12 @@ export const actionHandlers = handleThunks({
|
|
|
|
}).request;
|
|
|
|
}).request;
|
|
|
|
|
|
|
|
|
|
|
|
promise.done((data) => {
|
|
|
|
promise.done((data) => {
|
|
|
|
|
|
|
|
const updatedItem = _.cloneDeep(data);
|
|
|
|
|
|
|
|
updatedItem.id = updatedItem.tmdbId;
|
|
|
|
|
|
|
|
|
|
|
|
dispatch(batchActions([
|
|
|
|
dispatch(batchActions([
|
|
|
|
updateItem({ section: 'movies', ...data }),
|
|
|
|
updateItem({ section: 'movies', ...data }),
|
|
|
|
|
|
|
|
updateItem({ section: 'addMovie', ...updatedItem }),
|
|
|
|
|
|
|
|
|
|
|
|
set({
|
|
|
|
set({
|
|
|
|
section,
|
|
|
|
section,
|
|
|
|