mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
Scene play and o-counter history view and editing (#4532)
Co-authored-by: randemgame <61895715+randemgame@users.noreply.github.com>
This commit is contained in:
@@ -44,10 +44,16 @@ const StashIDsField: React.FC<IStashIDsField> = ({ values }) => {
|
||||
return <StringListSelect value={values.map((v) => v.stash_id)} />;
|
||||
};
|
||||
|
||||
type MergeOptions = {
|
||||
values: GQL.SceneUpdateInput;
|
||||
includeViewHistory: boolean;
|
||||
includeOHistory: boolean;
|
||||
};
|
||||
|
||||
interface ISceneMergeDetailsProps {
|
||||
sources: GQL.SlimSceneDataFragment[];
|
||||
dest: GQL.SlimSceneDataFragment;
|
||||
onClose: (values?: GQL.SceneUpdateInput) => void;
|
||||
onClose: (options?: MergeOptions) => void;
|
||||
}
|
||||
|
||||
const SceneMergeDetails: React.FC<ISceneMergeDetailsProps> = ({
|
||||
@@ -558,41 +564,45 @@ const SceneMergeDetails: React.FC<ISceneMergeDetailsProps> = ({
|
||||
);
|
||||
}
|
||||
|
||||
function createValues(): GQL.SceneUpdateInput {
|
||||
function createValues(): MergeOptions {
|
||||
const all = [dest, ...sources];
|
||||
|
||||
// only set the cover image if it's different from the existing cover image
|
||||
const coverImage = image.useNewValue ? image.getNewValue() : undefined;
|
||||
|
||||
return {
|
||||
id: dest.id,
|
||||
title: title.getNewValue(),
|
||||
code: code.getNewValue(),
|
||||
urls: url.getNewValue(),
|
||||
date: date.getNewValue(),
|
||||
rating100: rating.getNewValue(),
|
||||
o_counter: oCounter.getNewValue(),
|
||||
play_count: playCount.getNewValue(),
|
||||
play_duration: playDuration.getNewValue(),
|
||||
gallery_ids: galleries.getNewValue(),
|
||||
studio_id: studio.getNewValue()?.stored_id,
|
||||
performer_ids: performers.getNewValue()?.map((p) => p.stored_id!),
|
||||
movies: movies.getNewValue()?.map((m) => {
|
||||
// find the equivalent movie in the original scenes
|
||||
const found = all
|
||||
.map((s) => s.movies)
|
||||
.flat()
|
||||
.find((mm) => mm.movie.id === m.stored_id);
|
||||
return {
|
||||
movie_id: m.stored_id!,
|
||||
scene_index: found!.scene_index,
|
||||
};
|
||||
}),
|
||||
tag_ids: tags.getNewValue()?.map((t) => t.stored_id!),
|
||||
details: details.getNewValue(),
|
||||
organized: organized.getNewValue(),
|
||||
stash_ids: stashIDs.getNewValue(),
|
||||
cover_image: coverImage,
|
||||
values: {
|
||||
id: dest.id,
|
||||
title: title.getNewValue(),
|
||||
code: code.getNewValue(),
|
||||
urls: url.getNewValue(),
|
||||
date: date.getNewValue(),
|
||||
rating100: rating.getNewValue(),
|
||||
o_counter: oCounter.getNewValue(),
|
||||
play_count: playCount.getNewValue(),
|
||||
play_duration: playDuration.getNewValue(),
|
||||
gallery_ids: galleries.getNewValue(),
|
||||
studio_id: studio.getNewValue()?.stored_id,
|
||||
performer_ids: performers.getNewValue()?.map((p) => p.stored_id!),
|
||||
movies: movies.getNewValue()?.map((m) => {
|
||||
// find the equivalent movie in the original scenes
|
||||
const found = all
|
||||
.map((s) => s.movies)
|
||||
.flat()
|
||||
.find((mm) => mm.movie.id === m.stored_id);
|
||||
return {
|
||||
movie_id: m.stored_id!,
|
||||
scene_index: found!.scene_index,
|
||||
};
|
||||
}),
|
||||
tag_ids: tags.getNewValue()?.map((t) => t.stored_id!),
|
||||
details: details.getNewValue(),
|
||||
organized: organized.getNewValue(),
|
||||
stash_ids: stashIDs.getNewValue(),
|
||||
cover_image: coverImage,
|
||||
},
|
||||
includeViewHistory: playCount.getNewValue() !== undefined,
|
||||
includeOHistory: oCounter.getNewValue() !== undefined,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -679,13 +689,16 @@ export const SceneMergeModal: React.FC<ISceneMergeModalProps> = ({
|
||||
setSecondStep(true);
|
||||
}
|
||||
|
||||
async function onMerge(values: GQL.SceneUpdateInput) {
|
||||
async function onMerge(options: MergeOptions) {
|
||||
const { values, includeViewHistory, includeOHistory } = options;
|
||||
try {
|
||||
setRunning(true);
|
||||
const result = await mutateSceneMerge(
|
||||
destScene[0].id,
|
||||
sourceScenes.map((s) => s.id),
|
||||
values
|
||||
values,
|
||||
includeViewHistory,
|
||||
includeOHistory
|
||||
);
|
||||
if (result.data?.sceneMerge) {
|
||||
Toast.success(intl.formatMessage({ id: "toast.merged_scenes" }));
|
||||
|
||||
Reference in New Issue
Block a user