mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 16:34:02 +01:00
* Don't set image title to filename in graphql * Remove deprecated files field from image fragments
56 lines
1.2 KiB
TypeScript
56 lines
1.2 KiB
TypeScript
import TextUtils from "src/utils/text";
|
|
import * as GQL from "src/core/generated-graphql";
|
|
|
|
export interface IFile {
|
|
path: string;
|
|
}
|
|
|
|
interface IObjectWithFiles {
|
|
files?: IFile[];
|
|
}
|
|
|
|
export interface IObjectWithTitleFiles extends IObjectWithFiles {
|
|
title?: GQL.Maybe<string>;
|
|
}
|
|
|
|
export function objectTitle(s: Partial<IObjectWithTitleFiles>) {
|
|
if (s.title) {
|
|
return s.title;
|
|
}
|
|
if (s.files && s.files.length > 0) {
|
|
return TextUtils.fileNameFromPath(s.files[0].path);
|
|
}
|
|
return "";
|
|
}
|
|
|
|
export function objectPath(s: IObjectWithFiles) {
|
|
if (s.files && s.files.length > 0) {
|
|
return s.files[0].path;
|
|
}
|
|
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 "";
|
|
}
|