Skip to content

Commit

Permalink
Add suggestion from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
obulat committed Jul 12, 2023
1 parent c05250e commit c0e7106
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions frontend/src/types/media.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { SupportedMediaType } from "~/constants/media"
import type { License, LicenseVersion } from "~/constants/license"
import type { Sensitivity } from "~/constants/content-safety"
import { AUDIO, IMAGE } from "~/constants/media"

export interface Tag {
name: string
Expand Down Expand Up @@ -109,16 +110,14 @@ export interface ImageDimensions {
export type AspectRatio = "square" | "intrinsic"

export const isDetail = {
audio: (media: AudioDetail | ImageDetail | null): media is AudioDetail => {
return !!media && media.frontendMediaType === "audio"
},
image: (media: AudioDetail | ImageDetail | null): media is ImageDetail => {
return !!media && media.frontendMediaType === "image"
},
audio: (media: Media | null): media is AudioDetail =>
isMediaDetail<typeof AUDIO>(media, AUDIO),
image: (media: Media | null): media is ImageDetail =>
isMediaDetail<typeof IMAGE>(media, IMAGE),
}

export const isMediaDetail = <T extends SupportedMediaType>(
media: AudioDetail | ImageDetail | null,
media: Media | null,
mediaType: T
): media is DetailFromMediaType<T> => {
return !!media && media.frontendMediaType === mediaType
Expand Down

0 comments on commit c0e7106

Please sign in to comment.