Skip to content

Commit

Permalink
refactor: remove ValidCardShapes type union - it duplicates CardShapes
Browse files Browse the repository at this point in the history
  • Loading branch information
aweebs authored and ferferga committed Mar 19, 2023
1 parent efbb330 commit 1ad57fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
15 changes: 7 additions & 8 deletions frontend/src/utils/images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ import {
ImageType
} from '@jellyfin/sdk/lib/generated-client';
import { useRemote } from '@/composables';
import {
getShapeFromItemType,
ValidCardShapes,
isPerson,
CardShapes
} from '@/utils/items';
import { getShapeFromItemType, isPerson, CardShapes } from '@/utils/items';

export interface ImageUrlInfo {
url: string | undefined;
Expand Down Expand Up @@ -108,6 +103,7 @@ export function getParentId(item: BaseItemDto): string | undefined {
return item.ParentId;
}
}

/**
* Gets the blurhash string of an image given the item and the image type desired.
*
Expand Down Expand Up @@ -135,6 +131,7 @@ export function getBlurhash(
}
}
}

/**
* Returns the aspect ratio that should be use
*/
Expand All @@ -153,7 +150,7 @@ export function getContainerAspectRatioForImageType(
* @param shape
* @returns
*/
export function getDesiredAspect(shape: ValidCardShapes): number {
export function getDesiredAspect(shape: CardShapes): number {
let aspectRatio;

switch (shape) {
Expand All @@ -177,6 +174,7 @@ export function getDesiredAspect(shape: ValidCardShapes): number {

return aspectRatio;
}

/**
* Generates the image information for a BaseItemDto or a BasePersonDto according to set priorities.
*
Expand Down Expand Up @@ -208,7 +206,7 @@ export function getImageInfo(
ratio = 1,
tag
}: {
shape?: ValidCardShapes;
shape?: CardShapes;
preferThumb?: boolean;
preferBanner?: boolean;
preferLogo?: boolean;
Expand Down Expand Up @@ -403,6 +401,7 @@ export function getImageInfo(
blurhash: imgType && imgTag ? item.ImageBlurHashes?.[imgType]?.[imgTag] : ''
};
}

/**
* Generates the logo information for a BaseItemDto or a BasePersonDto according to set priorities.
*
Expand Down
10 changes: 2 additions & 8 deletions frontend/src/utils/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ export enum CardShapes {
Banner = 'banner-card'
}

export type ValidCardShapes =
| CardShapes.Portrait
| CardShapes.Thumb
| CardShapes.Square
| CardShapes.Banner;

/**
* Determines if the item is a person
*
Expand Down Expand Up @@ -140,7 +134,7 @@ export function getLibraryIcon(
*/
export function getShapeFromCollectionType(
collectionType: string | null | undefined
): ValidCardShapes {
): CardShapes {
switch (collectionType?.toLowerCase()) {
case 'livetv':
case 'musicvideos': {
Expand All @@ -165,7 +159,7 @@ export function getShapeFromCollectionType(
*/
export function getShapeFromItemType(
itemType: BaseItemKind | null | undefined
): ValidCardShapes {
): CardShapes {
if (!itemType) {
return CardShapes.Portrait;
}
Expand Down

0 comments on commit 1ad57fc

Please sign in to comment.