mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 16:34:02 +01:00
Don't set image.title to file basename in graphql (#5658)
* Don't set image title to filename in graphql * Remove deprecated files field from image fragments
This commit is contained in:
parent
50a900e83c
commit
c8032f04fa
7 changed files with 31 additions and 25 deletions
|
|
@ -35,12 +35,6 @@ models:
|
||||||
model: github.com/stashapp/stash/internal/api.BoolMap
|
model: github.com/stashapp/stash/internal/api.BoolMap
|
||||||
PluginConfigMap:
|
PluginConfigMap:
|
||||||
model: github.com/stashapp/stash/internal/api.PluginConfigMap
|
model: github.com/stashapp/stash/internal/api.PluginConfigMap
|
||||||
# define to force resolvers
|
|
||||||
Image:
|
|
||||||
model: github.com/stashapp/stash/pkg/models.Image
|
|
||||||
fields:
|
|
||||||
title:
|
|
||||||
resolver: true
|
|
||||||
VideoFile:
|
VideoFile:
|
||||||
fields:
|
fields:
|
||||||
# override float fields - #1572
|
# override float fields - #1572
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,6 @@ func (r *imageResolver) getFiles(ctx context.Context, obj *models.Image) ([]mode
|
||||||
return files, firstError(errs)
|
return files, firstError(errs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *imageResolver) Title(ctx context.Context, obj *models.Image) (*string, error) {
|
|
||||||
ret := obj.GetTitle()
|
|
||||||
return &ret, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *imageResolver) VisualFiles(ctx context.Context, obj *models.Image) ([]VisualFile, error) {
|
func (r *imageResolver) VisualFiles(ctx context.Context, obj *models.Image) ([]VisualFile, error) {
|
||||||
files, err := r.getFiles(ctx, obj)
|
files, err := r.getFiles(ctx, obj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,6 @@ fragment SlimImageData on Image {
|
||||||
organized
|
organized
|
||||||
o_counter
|
o_counter
|
||||||
|
|
||||||
files {
|
|
||||||
...ImageFileData
|
|
||||||
}
|
|
||||||
|
|
||||||
paths {
|
paths {
|
||||||
thumbnail
|
thumbnail
|
||||||
preview
|
preview
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,6 @@ fragment ImageData on Image {
|
||||||
created_at
|
created_at
|
||||||
updated_at
|
updated_at
|
||||||
|
|
||||||
files {
|
|
||||||
...ImageFileData
|
|
||||||
}
|
|
||||||
|
|
||||||
paths {
|
paths {
|
||||||
thumbnail
|
thumbnail
|
||||||
preview
|
preview
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import {
|
||||||
faSearch,
|
faSearch,
|
||||||
faTag,
|
faTag,
|
||||||
} from "@fortawesome/free-solid-svg-icons";
|
} from "@fortawesome/free-solid-svg-icons";
|
||||||
import { objectTitle } from "src/core/files";
|
import { imageTitle } from "src/core/files";
|
||||||
import { TruncatedText } from "../Shared/TruncatedText";
|
import { TruncatedText } from "../Shared/TruncatedText";
|
||||||
import ScreenUtils from "src/utils/screen";
|
import ScreenUtils from "src/utils/screen";
|
||||||
import { StudioOverlay } from "../Shared/GridCard/StudioOverlay";
|
import { StudioOverlay } from "../Shared/GridCard/StudioOverlay";
|
||||||
|
|
@ -197,7 +197,7 @@ export const ImageCard: React.FC<IImageCardProps> = (
|
||||||
className={`image-card zoom-${props.zoomIndex}`}
|
className={`image-card zoom-${props.zoomIndex}`}
|
||||||
url={`/images/${props.image.id}`}
|
url={`/images/${props.image.id}`}
|
||||||
width={cardWidth}
|
width={cardWidth}
|
||||||
title={objectTitle(props.image)}
|
title={imageTitle(props.image)}
|
||||||
linkClassName="image-card-link"
|
linkClassName="image-card-link"
|
||||||
image={
|
image={
|
||||||
<>
|
<>
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ import { ImageEditPanel } from "./ImageEditPanel";
|
||||||
import { ImageDetailPanel } from "./ImageDetailPanel";
|
import { ImageDetailPanel } from "./ImageDetailPanel";
|
||||||
import { DeleteImagesDialog } from "../DeleteImagesDialog";
|
import { DeleteImagesDialog } from "../DeleteImagesDialog";
|
||||||
import { faEllipsisV } from "@fortawesome/free-solid-svg-icons";
|
import { faEllipsisV } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { objectPath, objectTitle } from "src/core/files";
|
import { imagePath, imageTitle } from "src/core/files";
|
||||||
import { isVideo } from "src/utils/visualFile";
|
import { isVideo } from "src/utils/visualFile";
|
||||||
import { useScrollToTopOnMount } from "src/hooks/scrollToTop";
|
import { useScrollToTopOnMount } from "src/hooks/scrollToTop";
|
||||||
import { useRatingKeybinds } from "src/hooks/keybinds";
|
import { useRatingKeybinds } from "src/hooks/keybinds";
|
||||||
|
|
@ -79,7 +79,7 @@ const ImagePage: React.FC<IProps> = ({ image }) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
await mutateMetadataScan({
|
await mutateMetadataScan({
|
||||||
paths: [objectPath(image)],
|
paths: [imagePath(image)],
|
||||||
rescan: true,
|
rescan: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -274,11 +274,11 @@ const ImagePage: React.FC<IProps> = ({ image }) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const file = useMemo(
|
const file = useMemo(
|
||||||
() => (image.files.length > 0 ? image.files[0] : undefined),
|
() => (image.visual_files.length > 0 ? image.visual_files[0] : undefined),
|
||||||
[image]
|
[image]
|
||||||
);
|
);
|
||||||
|
|
||||||
const title = objectTitle(image);
|
const title = imageTitle(image);
|
||||||
const ImageView =
|
const ImageView =
|
||||||
image.visual_files.length > 0 && isVideo(image.visual_files[0])
|
image.visual_files.length > 0 && isVideo(image.visual_files[0])
|
||||||
? "video"
|
? "video"
|
||||||
|
|
|
||||||
|
|
@ -29,3 +29,28 @@ export function objectPath(s: IObjectWithFiles) {
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface IObjectWithVisualFiles {
|
||||||
|
visual_files?: IFile[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IObjectWithTitleVisualFiles extends IObjectWithVisualFiles {
|
||||||
|
title?: GQL.Maybe<string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function imageTitle(s: Partial<IObjectWithTitleVisualFiles>) {
|
||||||
|
if (s.title) {
|
||||||
|
return s.title;
|
||||||
|
}
|
||||||
|
if (s.visual_files && s.visual_files.length > 0) {
|
||||||
|
return TextUtils.fileNameFromPath(s.visual_files[0].path);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
export function imagePath(s: IObjectWithVisualFiles) {
|
||||||
|
if (s.visual_files && s.visual_files.length > 0) {
|
||||||
|
return s.visual_files[0].path;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue