mirror of
https://github.com/stashapp/stash.git
synced 2025-12-14 20:33:16 +01:00
Fix scene edit panel not updating on scene change (#2471)
This commit is contained in:
parent
92320b3418
commit
e76e4c978f
1 changed files with 20 additions and 16 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import React, { useEffect, useState } from "react";
|
||||
import React, { useEffect, useState, useMemo } from "react";
|
||||
import { FormattedMessage, useIntl } from "react-intl";
|
||||
import {
|
||||
Button,
|
||||
|
|
@ -107,27 +107,31 @@ export const SceneEditPanel: React.FC<IProps> = ({
|
|||
stash_ids: yup.mixed<GQL.StashIdInput>().optional().nullable(),
|
||||
});
|
||||
|
||||
const initialValues = {
|
||||
title: scene.title ?? "",
|
||||
details: scene.details ?? "",
|
||||
url: scene.url ?? "",
|
||||
date: scene.date ?? "",
|
||||
rating: scene.rating ?? null,
|
||||
gallery_ids: (scene.galleries ?? []).map((g) => g.id),
|
||||
studio_id: scene.studio?.id,
|
||||
performer_ids: (scene.performers ?? []).map((p) => p.id),
|
||||
movies: (scene.movies ?? []).map((m) => {
|
||||
return { movie_id: m.movie.id, scene_index: m.scene_index };
|
||||
const initialValues = useMemo(
|
||||
() => ({
|
||||
title: scene.title ?? "",
|
||||
details: scene.details ?? "",
|
||||
url: scene.url ?? "",
|
||||
date: scene.date ?? "",
|
||||
rating: scene.rating ?? null,
|
||||
gallery_ids: (scene.galleries ?? []).map((g) => g.id),
|
||||
studio_id: scene.studio?.id,
|
||||
performer_ids: (scene.performers ?? []).map((p) => p.id),
|
||||
movies: (scene.movies ?? []).map((m) => {
|
||||
return { movie_id: m.movie.id, scene_index: m.scene_index };
|
||||
}),
|
||||
tag_ids: (scene.tags ?? []).map((t) => t.id),
|
||||
cover_image: undefined,
|
||||
stash_ids: getStashIDs(scene.stash_ids),
|
||||
}),
|
||||
tag_ids: (scene.tags ?? []).map((t) => t.id),
|
||||
cover_image: undefined,
|
||||
stash_ids: getStashIDs(scene.stash_ids),
|
||||
};
|
||||
[scene]
|
||||
);
|
||||
|
||||
type InputValues = typeof initialValues;
|
||||
|
||||
const formik = useFormik({
|
||||
initialValues,
|
||||
enableReinitialize: true,
|
||||
validationSchema: schema,
|
||||
onSubmit: (values) => onSave(getSceneInput(values)),
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue