mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 08:26:00 +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
|
||||
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:
|
||||
fields:
|
||||
# override float fields - #1572
|
||||
|
|
|
|||
|
|
@ -18,11 +18,6 @@ func (r *imageResolver) getFiles(ctx context.Context, obj *models.Image) ([]mode
|
|||
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) {
|
||||
files, err := r.getFiles(ctx, obj)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -10,10 +10,6 @@ fragment SlimImageData on Image {
|
|||
organized
|
||||
o_counter
|
||||
|
||||
files {
|
||||
...ImageFileData
|
||||
}
|
||||
|
||||
paths {
|
||||
thumbnail
|
||||
preview
|
||||
|
|
|
|||
|
|
@ -12,10 +12,6 @@ fragment ImageData on Image {
|
|||
created_at
|
||||
updated_at
|
||||
|
||||
files {
|
||||
...ImageFileData
|
||||
}
|
||||
|
||||
paths {
|
||||
thumbnail
|
||||
preview
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import {
|
|||
faSearch,
|
||||
faTag,
|
||||
} from "@fortawesome/free-solid-svg-icons";
|
||||
import { objectTitle } from "src/core/files";
|
||||
import { imageTitle } from "src/core/files";
|
||||
import { TruncatedText } from "../Shared/TruncatedText";
|
||||
import ScreenUtils from "src/utils/screen";
|
||||
import { StudioOverlay } from "../Shared/GridCard/StudioOverlay";
|
||||
|
|
@ -197,7 +197,7 @@ export const ImageCard: React.FC<IImageCardProps> = (
|
|||
className={`image-card zoom-${props.zoomIndex}`}
|
||||
url={`/images/${props.image.id}`}
|
||||
width={cardWidth}
|
||||
title={objectTitle(props.image)}
|
||||
title={imageTitle(props.image)}
|
||||
linkClassName="image-card-link"
|
||||
image={
|
||||
<>
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import { ImageEditPanel } from "./ImageEditPanel";
|
|||
import { ImageDetailPanel } from "./ImageDetailPanel";
|
||||
import { DeleteImagesDialog } from "../DeleteImagesDialog";
|
||||
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 { useScrollToTopOnMount } from "src/hooks/scrollToTop";
|
||||
import { useRatingKeybinds } from "src/hooks/keybinds";
|
||||
|
|
@ -79,7 +79,7 @@ const ImagePage: React.FC<IProps> = ({ image }) => {
|
|||
}
|
||||
|
||||
await mutateMetadataScan({
|
||||
paths: [objectPath(image)],
|
||||
paths: [imagePath(image)],
|
||||
rescan: true,
|
||||
});
|
||||
|
||||
|
|
@ -274,11 +274,11 @@ const ImagePage: React.FC<IProps> = ({ image }) => {
|
|||
});
|
||||
|
||||
const file = useMemo(
|
||||
() => (image.files.length > 0 ? image.files[0] : undefined),
|
||||
() => (image.visual_files.length > 0 ? image.visual_files[0] : undefined),
|
||||
[image]
|
||||
);
|
||||
|
||||
const title = objectTitle(image);
|
||||
const title = imageTitle(image);
|
||||
const ImageView =
|
||||
image.visual_files.length > 0 && isVideo(image.visual_files[0])
|
||||
? "video"
|
||||
|
|
|
|||
|
|
@ -29,3 +29,28 @@ export function objectPath(s: IObjectWithFiles) {
|
|||
}
|
||||
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