Normalize to double quotes across all files with Prettier
This commit is contained in:
1 parent
73bff72cec
commit
a5659cf4c8
190 files changed
+9523
-8859
No files matched your search
@@ -1,29 +1,29 @@
|
||||
import { getMediaUrl, getTmdbImageUrl } from '@/lib/api';
|
||||
import type { Entry, Collection, Media } from '@/types';
|
||||
import { getMediaUrl, getTmdbImageUrl } from "@/lib/api";
|
||||
import type { Entry, Collection, Media } from "@/types";
|
||||
|
||||
const DEFAULT_POSTER = '/images/default-poster.png';
|
||||
const DEFAULT_POSTER = "/images/default-poster.png";
|
||||
|
||||
export function getPosterUrl(entry: Entry): string {
|
||||
// Not in library, use TMDB poster
|
||||
if (!entry.isInLibrary) {
|
||||
return entry.poster_path
|
||||
? getTmdbImageUrl(entry.poster_path, 'w342')
|
||||
? getTmdbImageUrl(entry.poster_path, "w342")
|
||||
: DEFAULT_POSTER;
|
||||
}
|
||||
|
||||
// In library: try local selected poster
|
||||
if (entry.medias) {
|
||||
const selectedPoster = entry.medias.find(
|
||||
(m: Media) => m.type === 'poster' && m.is_selected
|
||||
(m: Media) => m.type === "poster" && m.is_selected,
|
||||
);
|
||||
if (selectedPoster?.path) {
|
||||
return getMediaUrl('entries', 'posters', 'preview', selectedPoster.path);
|
||||
return getMediaUrl("entries", "posters", "preview", selectedPoster.path);
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to TMDB poster
|
||||
if (entry.poster_path) {
|
||||
return getTmdbImageUrl(entry.poster_path, 'w300');
|
||||
return getTmdbImageUrl(entry.poster_path, "w300");
|
||||
}
|
||||
|
||||
return DEFAULT_POSTER;
|
||||
@@ -32,28 +32,23 @@ export function getPosterUrl(entry: Entry): string {
|
||||
export function getBackdropUrl(entry: Entry): string {
|
||||
if (entry.medias) {
|
||||
const selectedBackdrop = entry.medias.find(
|
||||
(m: Media) => m.type === 'backdrop' && m.is_selected
|
||||
(m: Media) => m.type === "backdrop" && m.is_selected,
|
||||
);
|
||||
if (selectedBackdrop?.path) {
|
||||
return getMediaUrl(
|
||||
'entries',
|
||||
'backdrops',
|
||||
'full',
|
||||
selectedBackdrop.path
|
||||
);
|
||||
return getMediaUrl("entries", "backdrops", "full", selectedBackdrop.path);
|
||||
}
|
||||
}
|
||||
|
||||
if (entry.banner_path) {
|
||||
return getTmdbImageUrl(entry.banner_path, 'w1280');
|
||||
return getTmdbImageUrl(entry.banner_path, "w1280");
|
||||
}
|
||||
|
||||
return '';
|
||||
return "";
|
||||
}
|
||||
|
||||
export function getTmdbPosterUrl(
|
||||
posterPath: string | null,
|
||||
size = 'w342'
|
||||
size = "w342",
|
||||
): string {
|
||||
if (!posterPath) return DEFAULT_POSTER;
|
||||
return getTmdbImageUrl(posterPath, size);
|
||||
@@ -62,14 +57,19 @@ export function getTmdbPosterUrl(
|
||||
export function getCollectionBackdropUrl(collection: Collection): string {
|
||||
if (collection.medias) {
|
||||
const selectedBackdrop = collection.medias.find(
|
||||
(m: Media) => m.type === 'backdrop' && m.is_selected
|
||||
(m: Media) => m.type === "backdrop" && m.is_selected,
|
||||
);
|
||||
if (selectedBackdrop?.path) {
|
||||
return getMediaUrl('collections', 'backdrops', 'full', selectedBackdrop.path);
|
||||
return getMediaUrl(
|
||||
"collections",
|
||||
"backdrops",
|
||||
"full",
|
||||
selectedBackdrop.path,
|
||||
);
|
||||
}
|
||||
}
|
||||
if (collection.backdrop_path) {
|
||||
return getTmdbImageUrl(collection.backdrop_path, 'w780');
|
||||
return getTmdbImageUrl(collection.backdrop_path, "w780");
|
||||
}
|
||||
return getCollectionPosterUrl(collection);
|
||||
}
|
||||
@@ -77,42 +77,47 @@ export function getCollectionBackdropUrl(collection: Collection): string {
|
||||
export function getCollectionPosterUrl(collection: Collection): string {
|
||||
if (collection.medias) {
|
||||
const selectedPoster = collection.medias.find(
|
||||
(m: Media) => m.type === 'poster' && m.is_selected
|
||||
(m: Media) => m.type === "poster" && m.is_selected,
|
||||
);
|
||||
if (selectedPoster?.path) {
|
||||
return getMediaUrl('collections', 'posters', 'preview', selectedPoster.path);
|
||||
return getMediaUrl(
|
||||
"collections",
|
||||
"posters",
|
||||
"preview",
|
||||
selectedPoster.path,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (collection.poster_path) {
|
||||
return getTmdbImageUrl(collection.poster_path, 'w342');
|
||||
return getTmdbImageUrl(collection.poster_path, "w342");
|
||||
}
|
||||
|
||||
return DEFAULT_POSTER;
|
||||
}
|
||||
|
||||
export function getProfileUrl(profilePath: string | null): string {
|
||||
if (!profilePath) return '/images/default-profile.png';
|
||||
return getTmdbImageUrl(profilePath, 'w185');
|
||||
if (!profilePath) return "/images/default-profile.png";
|
||||
return getTmdbImageUrl(profilePath, "w185");
|
||||
}
|
||||
|
||||
export function formatRuntime(minutes: number | null): string {
|
||||
if (!minutes) return '';
|
||||
if (!minutes) return "";
|
||||
const h = Math.floor(minutes / 60);
|
||||
const m = minutes % 60;
|
||||
return h > 0 ? `${h}h ${m}m` : `${m}m`;
|
||||
}
|
||||
|
||||
export function formatDate(dateStr: string | null): string {
|
||||
if (!dateStr) return '';
|
||||
return new Date(dateStr).toLocaleDateString('en-US', {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
if (!dateStr) return "";
|
||||
return new Date(dateStr).toLocaleDateString("en-US", {
|
||||
year: "numeric",
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
});
|
||||
}
|
||||
|
||||
export function getYear(dateStr: string | null): string {
|
||||
if (!dateStr) return '';
|
||||
if (!dateStr) return "";
|
||||
return new Date(dateStr).getFullYear().toString();
|
||||
}
|
||||
Reference in new issue
Block a user