diff --git a/packages/components/src/api/_common/enums/MediaFileType.ts b/packages/components/src/api/_common/enums/MediaFileType.ts index b104aeaa7b..6f1ff419ed 100644 --- a/packages/components/src/api/_common/enums/MediaFileType.ts +++ b/packages/components/src/api/_common/enums/MediaFileType.ts @@ -1,6 +1,6 @@ - export enum MediaFileType { Audio = "audio", Video = "video", Image = "image", + None = "none", } diff --git a/packages/components/src/api/media_files/GetMediaFile.ts b/packages/components/src/api/media_files/GetMediaFile.ts index 29bdc1a7fc..4177077788 100644 --- a/packages/components/src/api/media_files/GetMediaFile.ts +++ b/packages/components/src/api/media_files/GetMediaFile.ts @@ -1,15 +1,25 @@ import { ApiConfig } from "../ApiConfig"; import { UserDetailsLight } from "../_common/UserDetailsLight"; import { MediaFileType } from "../_common/enums/MediaFileType"; +import { WeightCategory } from "../_common/enums/WeightCategory"; +import { WeightType } from "../_common/enums/WeightType"; +// import { Weight } from "../weights/GetWeight"; export interface MediaFile { - token: string, - media_type: MediaFileType, - public_bucket_path: string, - maybe_creator_user: UserDetailsLight | null, - creator_set_visibility: string, - created_at: Date, - updated_at: Date, + token: string; + media_type: MediaFileType; + public_bucket_path: string; + maybe_creator_user?: UserDetailsLight | null; + creator_set_visibility: string; + created_at: Date; + updated_at: Date; + maybe_model_weight_info?: { + title: string; + weight_token: string; + weight_category: WeightCategory; + weight_type: WeightType; + maybe_weight_creator: UserDetailsLight; + }; } export enum MediaFileLookupError { @@ -19,34 +29,40 @@ export enum MediaFileLookupError { } export interface GetMediaFileResponse { - success: boolean, - media_file?: MediaFile, + success: boolean; + media_file?: MediaFile; } -export async function GetMediaFile(mediaFileToken: string) : Promise { +export async function GetMediaFile( + mediaFileToken: string +): Promise { const endpoint = new ApiConfig().getMediaFile(mediaFileToken); - - return await fetch(endpoint, { - method: 'GET', - headers: { - 'Accept': 'application/json', - }, - credentials: 'include', - }) - .then(res => res.json()) - .then(res => { - const response : GetMediaFileResponse = res; - if (response && response.success && response.media_file) { - // NB: Timestamps aren't converted to Date objects on their own! - response.media_file.created_at = new Date(response.media_file.created_at); - response.media_file.updated_at = new Date(response.media_file.updated_at); - return response; - } else { - return { success : false }; - } + return await fetch(endpoint, { + method: "GET", + headers: { + Accept: "application/json", + }, + credentials: "include", }) - .catch(e => { - return { success : false }; - }); + .then(res => res.json()) + .then(res => { + const response: GetMediaFileResponse = res; + + if (response && response.success && response.media_file) { + // NB: Timestamps aren't converted to Date objects on their own! + response.media_file.created_at = new Date( + response.media_file.created_at + ); + response.media_file.updated_at = new Date( + response.media_file.updated_at + ); + return response; + } else { + return { success: false }; + } + }) + .catch(e => { + return { success: false }; + }); } diff --git a/packages/fakeyou.com/src/components/common/ShareButton/ShareButton.tsx b/packages/fakeyou.com/src/components/common/ShareButton/ShareButton.tsx index ed1fe885d2..1351dcda02 100644 --- a/packages/fakeyou.com/src/components/common/ShareButton/ShareButton.tsx +++ b/packages/fakeyou.com/src/components/common/ShareButton/ShareButton.tsx @@ -26,7 +26,7 @@ export default function ShareButton(props: ShareButtonProps) {
setButtonLabel("Copy"), 1000); }; + const subtitleDivider = |; + return (
- + + +
+
+
+

+ {mediaFile.maybe_model_weight_info?.title || + `Media ${mediaType}`} +

+
+
+
+
+ +
+ {subtitleDivider} + + {mediaFile.maybe_model_weight_info && ( + <> +

+ {mediaFile.maybe_model_weight_info?.weight_category} +

+ {subtitleDivider} + + )} + +
+ + {/* */} +
+
+
+
+
+
+
@@ -374,30 +435,46 @@ export default function MediaPage({ sessionWrapper }: MediaPageProps) {

Anonymous

)} -

Created: {timeCreated}

+

Created {timeCreated}

- -
-
Weight Used
-
-
- -
- -
Weight Name
- -

by hanashi

+ {mediaFile.maybe_model_weight_info && ( + +
+
Weight Used
+
+
+ +
+ +
+ {mediaFile.maybe_model_weight_info.title} +
+ +

+ by{" "} + + { + mediaFile.maybe_model_weight_info + .maybe_weight_creator.display_name + } + +

+
-
- + + )}