mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Fix scene edit panel not updating on scene change (#2471)
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState, useMemo } from "react";
|
||||||
import { FormattedMessage, useIntl } from "react-intl";
|
import { FormattedMessage, useIntl } from "react-intl";
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
@@ -107,7 +107,8 @@ export const SceneEditPanel: React.FC<IProps> = ({
|
|||||||
stash_ids: yup.mixed<GQL.StashIdInput>().optional().nullable(),
|
stash_ids: yup.mixed<GQL.StashIdInput>().optional().nullable(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const initialValues = {
|
const initialValues = useMemo(
|
||||||
|
() => ({
|
||||||
title: scene.title ?? "",
|
title: scene.title ?? "",
|
||||||
details: scene.details ?? "",
|
details: scene.details ?? "",
|
||||||
url: scene.url ?? "",
|
url: scene.url ?? "",
|
||||||
@@ -122,12 +123,15 @@ export const SceneEditPanel: React.FC<IProps> = ({
|
|||||||
tag_ids: (scene.tags ?? []).map((t) => t.id),
|
tag_ids: (scene.tags ?? []).map((t) => t.id),
|
||||||
cover_image: undefined,
|
cover_image: undefined,
|
||||||
stash_ids: getStashIDs(scene.stash_ids),
|
stash_ids: getStashIDs(scene.stash_ids),
|
||||||
};
|
}),
|
||||||
|
[scene]
|
||||||
|
);
|
||||||
|
|
||||||
type InputValues = typeof initialValues;
|
type InputValues = typeof initialValues;
|
||||||
|
|
||||||
const formik = useFormik({
|
const formik = useFormik({
|
||||||
initialValues,
|
initialValues,
|
||||||
|
enableReinitialize: true,
|
||||||
validationSchema: schema,
|
validationSchema: schema,
|
||||||
onSubmit: (values) => onSave(getSceneInput(values)),
|
onSubmit: (values) => onSave(getSceneInput(values)),
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user