Skip to content

Commit

Permalink
Remove deprecated files field from image fragments
Browse files Browse the repository at this point in the history
  • Loading branch information
WithoutPants committed Feb 12, 2025
1 parent a044ff2 commit 93a172e
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 14 deletions.
4 changes: 0 additions & 4 deletions ui/v2.5/graphql/data/image-slim.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ fragment SlimImageData on Image {
organized
o_counter

files {
...ImageFileData
}

paths {
thumbnail
preview
Expand Down
4 changes: 0 additions & 4 deletions ui/v2.5/graphql/data/image.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ fragment ImageData on Image {
created_at
updated_at

files {
...ImageFileData
}

paths {
thumbnail
preview
Expand Down
4 changes: 2 additions & 2 deletions ui/v2.5/src/components/Images/ImageCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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={
<>
Expand Down
8 changes: 4 additions & 4 deletions ui/v2.5/src/components/Images/ImageDetails/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -79,7 +79,7 @@ const ImagePage: React.FC<IProps> = ({ image }) => {
}

await mutateMetadataScan({
paths: [objectPath(image)],
paths: [imagePath(image)],
rescan: true,
});

Expand Down Expand Up @@ -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"
Expand Down
25 changes: 25 additions & 0 deletions ui/v2.5/src/core/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 "";
}

0 comments on commit 93a172e

Please sign in to comment.