feat: add gamepad navigation and music library improvements
Continuous Integration / build_web (push) Failing after 0s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped
Continuous Integration / build_web (push) Failing after 0s
Continuous Integration / build (macos-latest) (push) Skipped
Continuous Integration / build (ubuntu-22.04) (push) Skipped
Continuous Integration / build (windows-11-arm) (push) Skipped
Continuous Integration / build (windows-latest) (push) Skipped
Continuous Integration / nightly_release (push) Skipped
- add TV/gamepad spatial navigation, focus ring and back/select controls - cache artwork persistently and add music cover placeholders - add compact songs list, shuffle-all queue and library error recovery - polish remote control layout and optimistic seek timeline
This commit is contained in:
1 parent
04ab9f767b
commit
5f5803c9f8
24 files changed
+1197
-243
No files matched your search
@@ -72,6 +72,17 @@ export default function AlbumMusicTrack(props: AlbumMusicTrackProps) {
|
|||||||
handlePlayback(trackIndex, track, musicTracks.Items);
|
handlePlayback(trackIndex, track, musicTracks.Items);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
onKeyDown={(event) => {
|
||||||
|
if (event.key === "Enter" || event.key === " ") {
|
||||||
|
event.preventDefault();
|
||||||
|
if (musicTracks?.Items) {
|
||||||
|
handlePlayback(trackIndex, track, musicTracks.Items);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
role="button"
|
||||||
|
tabIndex={0}
|
||||||
|
aria-label={track.Name ?? "Трек"}
|
||||||
>
|
>
|
||||||
<div className="album-track-index">
|
<div className="album-track-index">
|
||||||
<span className="material-symbols-rounded album-track-play">
|
<span className="material-symbols-rounded album-track-play">
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
import React, { useEffect, useState } from "react";
|
||||||
|
import { getCachedImageUrl } from "@/utils/cache/imageCache";
|
||||||
|
|
||||||
|
type CachedImageProps = React.ImgHTMLAttributes<HTMLImageElement> & {
|
||||||
|
src?: string | null;
|
||||||
|
fallback?: React.ReactNode;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drop-in `<img>` that resolves Jellyfin artwork through the persistent
|
||||||
|
* Cache API. If the request cannot be read (CORS/offline), it falls back to
|
||||||
|
* the original URL so the browser can still render it.
|
||||||
|
*/
|
||||||
|
const CachedImage = ({
|
||||||
|
src,
|
||||||
|
fallback = null,
|
||||||
|
onError,
|
||||||
|
...props
|
||||||
|
}: CachedImageProps) => {
|
||||||
|
const [cachedSrc, setCachedSrc] = useState<string | null>(null);
|
||||||
|
const [failed, setFailed] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let active = true;
|
||||||
|
setCachedSrc(null);
|
||||||
|
setFailed(false);
|
||||||
|
if (!src) return;
|
||||||
|
void getCachedImageUrl(src).then((url) => {
|
||||||
|
if (active && url) setCachedSrc(url);
|
||||||
|
});
|
||||||
|
return () => {
|
||||||
|
active = false;
|
||||||
|
};
|
||||||
|
}, [src]);
|
||||||
|
|
||||||
|
if (!src || failed) return <>{fallback}</>;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<img
|
||||||
|
{...props}
|
||||||
|
src={cachedSrc ?? src}
|
||||||
|
onError={(event) => {
|
||||||
|
setFailed(true);
|
||||||
|
onError?.(event);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CachedImage;
|
||||||
@@ -9,6 +9,7 @@ import { useNavigate } from "@tanstack/react-router";
|
|||||||
import React, { memo, type Ref, useCallback } from "react";
|
import React, { memo, type Ref, useCallback } from "react";
|
||||||
import { ErrorBoundary } from "react-error-boundary";
|
import { ErrorBoundary } from "react-error-boundary";
|
||||||
import { useInView } from "react-intersection-observer";
|
import { useInView } from "react-intersection-observer";
|
||||||
|
import CachedImage from "@/components/cachedImage";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
import { resolveItemImage } from "@/utils/methods/itemImages";
|
import { resolveItemImage } from "@/utils/methods/itemImages";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
@@ -60,6 +61,14 @@ const CardContent = ({
|
|||||||
const image = resolveItemImage(item, imageType, {
|
const image = resolveItemImage(item, imageType, {
|
||||||
seriesId: seriesId ? (item.SeriesId ?? undefined) : undefined,
|
seriesId: seriesId ? (item.SeriesId ?? undefined) : undefined,
|
||||||
});
|
});
|
||||||
|
const isMusic =
|
||||||
|
item.Type === BaseItemKind.MusicAlbum ||
|
||||||
|
item.Type === BaseItemKind.Audio ||
|
||||||
|
item.Type === BaseItemKind.AudioBook ||
|
||||||
|
item.Type === BaseItemKind.Playlist;
|
||||||
|
// Jellyfin generates a generic placeholder when a music item has no cover;
|
||||||
|
// prefer our own themed fallback in that case.
|
||||||
|
const hasCover = !isMusic || Boolean(image?.tag);
|
||||||
|
|
||||||
const defaultOnClick = useCallback(() => {
|
const defaultOnClick = useCallback(() => {
|
||||||
if (item?.Id) {
|
if (item?.Id) {
|
||||||
@@ -72,6 +81,15 @@ const CardContent = ({
|
|||||||
className="card"
|
className="card"
|
||||||
ref={forwardedRef}
|
ref={forwardedRef}
|
||||||
onClick={onClick || defaultOnClick}
|
onClick={onClick || defaultOnClick}
|
||||||
|
onKeyDown={(event) => {
|
||||||
|
if (event.key === "Enter" || event.key === " ") {
|
||||||
|
event.preventDefault();
|
||||||
|
(onClick || defaultOnClick)();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
role="button"
|
||||||
|
tabIndex={0}
|
||||||
|
aria-label={cardTitle ?? item.Name ?? "Элемент"}
|
||||||
>
|
>
|
||||||
<div className={`card-image-container ${cardType}`}>
|
<div className={`card-image-container ${cardType}`}>
|
||||||
<ErrorBoundary fallback={<></>}>
|
<ErrorBoundary fallback={<></>}>
|
||||||
@@ -107,8 +125,8 @@ const CardContent = ({
|
|||||||
? getTypeIcon(overrideIcon)
|
? getTypeIcon(overrideIcon)
|
||||||
: getTypeIcon(item.Type ?? "universal")}
|
: getTypeIcon(item.Type ?? "universal")}
|
||||||
</div>
|
</div>
|
||||||
{image && (
|
{image && hasCover && (
|
||||||
<img
|
<CachedImage
|
||||||
alt={item.Name ?? "blink"}
|
alt={item.Name ?? "blink"}
|
||||||
decoding="async"
|
decoding="async"
|
||||||
src={
|
src={
|
||||||
@@ -136,7 +154,7 @@ const CardContent = ({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{inView && !disableOverlay && (
|
{inView && !disableOverlay && (
|
||||||
<div className="card-overlay">
|
<div className="card-overlay" data-tv-ignore>
|
||||||
<PlayButton
|
<PlayButton
|
||||||
item={item}
|
item={item}
|
||||||
userId={userId}
|
userId={userId}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import {
|
|||||||
getItemImagesQueryOptions,
|
getItemImagesQueryOptions,
|
||||||
resolveHeroArtwork,
|
resolveHeroArtwork,
|
||||||
} from "@/utils/methods/heroArtwork";
|
} from "@/utils/methods/heroArtwork";
|
||||||
|
import CachedImage from "@/components/cachedImage";
|
||||||
import BlurhashCanvas from "../blurhash-canvas";
|
import BlurhashCanvas from "../blurhash-canvas";
|
||||||
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
@@ -97,7 +98,7 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{heroArtwork ? (
|
{heroArtwork ? (
|
||||||
<img
|
<CachedImage
|
||||||
alt={item.Name ?? "item"}
|
alt={item.Name ?? "item"}
|
||||||
className={`hero-carousel-background-image${heroArtwork.isPortrait ? " is-poster" : ""}`}
|
className={`hero-carousel-background-image${heroArtwork.isPortrait ? " is-poster" : ""}`}
|
||||||
src={heroArtwork.url}
|
src={heroArtwork.url}
|
||||||
@@ -110,7 +111,7 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{heroPoster && (
|
{heroPoster && (
|
||||||
<img
|
<CachedImage
|
||||||
alt={item.Name ?? "poster"}
|
alt={item.Name ?? "poster"}
|
||||||
className="hero-carousel-poster"
|
className="hero-carousel-poster"
|
||||||
src={heroPoster}
|
src={heroPoster}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import hdr10Icon from "@/assets/icons/hdr10.svg";
|
|||||||
import hdr10PlusIcon from "@/assets/icons/hdr10-plus.svg";
|
import hdr10PlusIcon from "@/assets/icons/hdr10-plus.svg";
|
||||||
import sdIcon from "@/assets/icons/sd.svg";
|
import sdIcon from "@/assets/icons/sd.svg";
|
||||||
import sdrIcon from "@/assets/icons/sdr.svg";
|
import sdrIcon from "@/assets/icons/sdr.svg";
|
||||||
|
import CachedImage from "@/components/cachedImage";
|
||||||
import ItemBackdrop from "@/components/itemBackdrop";
|
import ItemBackdrop from "@/components/itemBackdrop";
|
||||||
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
import { getTypeIcon } from "@/components/utils/iconsCollection";
|
||||||
import { endsAt, getRuntime } from "@/utils/date/time";
|
import { endsAt, getRuntime } from "@/utils/date/time";
|
||||||
@@ -66,7 +67,7 @@ const ItemHeader = ({
|
|||||||
isEpisode && parentLogoImageTag ? (item.SeriesId ?? item.Id) : item.Id;
|
isEpisode && parentLogoImageTag ? (item.SeriesId ?? item.Id) : item.Id;
|
||||||
|
|
||||||
const logo = logoTag ? (
|
const logo = logoTag ? (
|
||||||
<img
|
<CachedImage
|
||||||
alt={item.Name ?? ""}
|
alt={item.Name ?? ""}
|
||||||
src={
|
src={
|
||||||
api &&
|
api &&
|
||||||
@@ -127,7 +128,7 @@ const ItemHeader = ({
|
|||||||
}
|
}
|
||||||
className="item-hero-image-blurhash"
|
className="item-hero-image-blurhash"
|
||||||
/>
|
/>
|
||||||
<img
|
<CachedImage
|
||||||
alt={item.Name ?? ""}
|
alt={item.Name ?? ""}
|
||||||
src={
|
src={
|
||||||
api &&
|
api &&
|
||||||
|
|||||||
@@ -1,22 +1,33 @@
|
|||||||
import type { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
import {
|
||||||
import { ItemSortBy, SortOrder } from "@jellyfin/sdk/lib/generated-client";
|
BaseItemKind,
|
||||||
|
ItemSortBy,
|
||||||
|
SortOrder,
|
||||||
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
import { getLibraryApi } from "@jellyfin/sdk/lib/utils/api/library-api";
|
||||||
import {
|
import {
|
||||||
AppBar,
|
AppBar,
|
||||||
|
Button,
|
||||||
Chip,
|
Chip,
|
||||||
IconButton,
|
IconButton,
|
||||||
MenuItem,
|
MenuItem,
|
||||||
TextField,
|
TextField,
|
||||||
|
Tooltip,
|
||||||
Typography,
|
Typography,
|
||||||
useScrollTrigger,
|
useScrollTrigger,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { useQueryClient, useSuspenseQuery } from "@tanstack/react-query";
|
import { useQueryClient, useSuspenseQuery } from "@tanstack/react-query";
|
||||||
|
import { useSnackbar } from "notistack";
|
||||||
import { getRouteApi, useNavigate } from "@tanstack/react-router";
|
import { getRouteApi, useNavigate } from "@tanstack/react-router";
|
||||||
import type { ChangeEvent } from "react";
|
import type { ChangeEvent } from "react";
|
||||||
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
import { AVAILABLE_VIEWS, SORT_BY_OPTIONS } from "@/utils/constants/library";
|
import { AVAILABLE_VIEWS, SORT_BY_OPTIONS } from "@/utils/constants/library";
|
||||||
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
import { getLibraryQueryOptions } from "@/utils/queries/library";
|
||||||
|
import {
|
||||||
|
generateAudioStreamUrl,
|
||||||
|
playAudio,
|
||||||
|
} from "@/utils/store/audioPlayback";
|
||||||
|
import { setQueue } from "@/utils/store/queue";
|
||||||
// import removed: header reads name/count from Zustand slice
|
// import removed: header reads name/count from Zustand slice
|
||||||
import { useLibraryStateStore } from "@/utils/store/libraryState";
|
import { useLibraryStateStore } from "@/utils/store/libraryState";
|
||||||
import useSearchStore from "@/utils/store/search";
|
import useSearchStore from "@/utils/store/search";
|
||||||
@@ -37,6 +48,8 @@ export const LibraryHeader = () => {
|
|||||||
const { api, user } = route.useRouteContext();
|
const { api, user } = route.useRouteContext();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
|
const [shuffling, setShuffling] = useState(false);
|
||||||
|
|
||||||
// Zustand library state (selected via shallow comparator)
|
// Zustand library state (selected via shallow comparator)
|
||||||
const {
|
const {
|
||||||
@@ -226,6 +239,70 @@ export const LibraryHeader = () => {
|
|||||||
[normalizedViewType, currentLibrary.data.CollectionType],
|
[normalizedViewType, currentLibrary.data.CollectionType],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const isMusicSongs =
|
||||||
|
currentLibrary.data.CollectionType === "music" &&
|
||||||
|
normalizedViewType === BaseItemKind.Audio;
|
||||||
|
|
||||||
|
const shuffleAllTracks = useCallback(async () => {
|
||||||
|
if (!api || !user?.Id || !currentLibraryId || shuffling) return;
|
||||||
|
setShuffling(true);
|
||||||
|
try {
|
||||||
|
const result = await getLibraryApi(api).getItems({
|
||||||
|
userId: user.Id,
|
||||||
|
parentId: currentLibraryId,
|
||||||
|
recursive: true,
|
||||||
|
includeItemTypes: [BaseItemKind.Audio],
|
||||||
|
sortBy: [ItemSortBy.SortName],
|
||||||
|
sortOrder: [SortOrder.Ascending],
|
||||||
|
enableUserData: true,
|
||||||
|
limit: 5000,
|
||||||
|
});
|
||||||
|
const tracks = (result.data.Items ?? []).filter((item) => item.Id);
|
||||||
|
if (tracks.length === 0) {
|
||||||
|
enqueueSnackbar("В этой библиотеке нет композиций", {
|
||||||
|
variant: "info",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const queue = [...tracks];
|
||||||
|
for (let i = queue.length - 1; i > 0; i--) {
|
||||||
|
const j = Math.floor(Math.random() * (i + 1));
|
||||||
|
[queue[i], queue[j]] = [queue[j], queue[i]];
|
||||||
|
}
|
||||||
|
const first = queue[0];
|
||||||
|
if (!first.Id) return;
|
||||||
|
playAudio(
|
||||||
|
generateAudioStreamUrl(
|
||||||
|
first.Id,
|
||||||
|
user.Id,
|
||||||
|
api.deviceInfo.id,
|
||||||
|
api.basePath,
|
||||||
|
api.accessToken,
|
||||||
|
),
|
||||||
|
first,
|
||||||
|
);
|
||||||
|
setQueue(queue, 0);
|
||||||
|
enqueueSnackbar(`Перемешано композиций: ${queue.length}`, {
|
||||||
|
variant: "success",
|
||||||
|
});
|
||||||
|
navigate({ to: "/player/audio" });
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Could not shuffle music library", error);
|
||||||
|
enqueueSnackbar("Не удалось запустить перемешивание", {
|
||||||
|
variant: "error",
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
setShuffling(false);
|
||||||
|
}
|
||||||
|
}, [
|
||||||
|
api,
|
||||||
|
user?.Id,
|
||||||
|
currentLibraryId,
|
||||||
|
shuffling,
|
||||||
|
enqueueSnackbar,
|
||||||
|
navigate,
|
||||||
|
]);
|
||||||
|
|
||||||
const appBarStyling = useMemo(
|
const appBarStyling = useMemo(
|
||||||
() => ({ backgroundColor: "transparent", paddingRight: "0 !important" }),
|
() => ({ backgroundColor: "transparent", paddingRight: "0 !important" }),
|
||||||
[],
|
[],
|
||||||
@@ -334,6 +411,30 @@ export const LibraryHeader = () => {
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
))}
|
))}
|
||||||
</TextField>
|
</TextField>
|
||||||
|
{isMusicSongs && (
|
||||||
|
<Tooltip title="Перемешать все композиции">
|
||||||
|
<Button
|
||||||
|
className="music-shuffle-button"
|
||||||
|
variant="contained"
|
||||||
|
size="small"
|
||||||
|
onClick={shuffleAllTracks}
|
||||||
|
disabled={shuffling}
|
||||||
|
startIcon={
|
||||||
|
<span className="material-symbols-rounded">shuffle</span>
|
||||||
|
}
|
||||||
|
sx={{
|
||||||
|
borderRadius: "999px",
|
||||||
|
textTransform: "none",
|
||||||
|
whiteSpace: "nowrap",
|
||||||
|
px: 2,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span className="music-shuffle-label">
|
||||||
|
{shuffling ? "Перемешиваем…" : "Перемешать"}
|
||||||
|
</span>
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={handleSortAscendingToggle}
|
onClick={handleSortAscendingToggle}
|
||||||
aria-label="Изменить порядок сортировки"
|
aria-label="Изменить порядок сортировки"
|
||||||
|
|||||||
@@ -51,3 +51,20 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.music-shuffle-button {
|
||||||
|
.material-symbols-rounded {
|
||||||
|
font-size: 1.15rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1200px) {
|
||||||
|
.music-shuffle-button .music-shuffle-label {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.music-shuffle-button {
|
||||||
|
min-width: 0;
|
||||||
|
padding: 6px 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,6 +23,7 @@ import { useCentralStore } from "@/utils/store/central";
|
|||||||
import { useLibraryStateStore } from "@/utils/store/libraryState";
|
import { useLibraryStateStore } from "@/utils/store/libraryState";
|
||||||
import BackdropWorker from "@/utils/workers/backdrop.worker?worker";
|
import BackdropWorker from "@/utils/workers/backdrop.worker?worker";
|
||||||
import { Card } from "../card/card";
|
import { Card } from "../card/card";
|
||||||
|
import MusicTracksList from "../musicTracksList";
|
||||||
|
|
||||||
const libraryRoute = getRouteApi("/_api/library/$id");
|
const libraryRoute = getRouteApi("/_api/library/$id");
|
||||||
|
|
||||||
@@ -264,6 +265,16 @@ const LibraryItemsGrid = () => {
|
|||||||
}
|
}
|
||||||
}, [items.data?.TotalRecordCount, currentLibraryId, updateLibrary]);
|
}, [items.data?.TotalRecordCount, currentLibraryId, updateLibrary]);
|
||||||
|
|
||||||
|
if (effectiveViewType === BaseItemKind.Audio) {
|
||||||
|
return (
|
||||||
|
<MusicTracksList
|
||||||
|
items={items.data?.Items ?? []}
|
||||||
|
userId={user?.Id}
|
||||||
|
queryKey={["library", "items", currentLibraryId]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
ref={parentRef}
|
ref={parentRef}
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import React from "react";
|
import React, { useRef } from "react";
|
||||||
import { getRuntimeMusic } from "../../utils/date/time";
|
import { getRuntimeMusic } from "../../utils/date/time";
|
||||||
import { useAudioPlayback } from "../../utils/store/audioPlayback";
|
import { useAudioPlayback } from "../../utils/store/audioPlayback";
|
||||||
import LikeButton from "../buttons/likeButton";
|
import LikeButton from "../buttons/likeButton";
|
||||||
import PlayButton from "../buttons/playButton";
|
import PlayButton from "../buttons/playButton";
|
||||||
import "./musicTrack.scss";
|
import "./musicTrack.scss";
|
||||||
|
import CachedImage from "@/components/cachedImage";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
|
import { resolveItemImage } from "@/utils/methods/itemImages";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { Link } from "@tanstack/react-router";
|
import { Link } from "@tanstack/react-router";
|
||||||
@@ -33,9 +35,45 @@ const MusicTrack = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const [currentTrackItem] = useAudioPlayback((state) => [state.item]);
|
const [currentTrackItem] = useAudioPlayback((state) => [state.item]);
|
||||||
|
const rowRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
const activate = () => {
|
||||||
|
rowRef.current
|
||||||
|
?.querySelector<HTMLElement>(".music-track-image-overlay button")
|
||||||
|
?.click();
|
||||||
|
};
|
||||||
|
const image = resolveItemImage(item);
|
||||||
|
const imageUrl =
|
||||||
|
api && image?.tag
|
||||||
|
? getImageUrlsApi(api).getItemImageUrlById(
|
||||||
|
image.itemId,
|
||||||
|
image.imageType,
|
||||||
|
{
|
||||||
|
quality: 70,
|
||||||
|
fillHeight: 128,
|
||||||
|
fillWidth: 128,
|
||||||
|
tag: image.tag,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`music-track ${className}`}>
|
<div
|
||||||
|
ref={rowRef}
|
||||||
|
className={`music-track ${className}`}
|
||||||
|
onClick={(event) => {
|
||||||
|
if ((event.target as HTMLElement).closest("a,button")) return;
|
||||||
|
activate();
|
||||||
|
}}
|
||||||
|
onKeyDown={(event) => {
|
||||||
|
if (event.key === "Enter" || event.key === " ") {
|
||||||
|
event.preventDefault();
|
||||||
|
activate();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
role="button"
|
||||||
|
tabIndex={0}
|
||||||
|
aria-label={item.Name ?? "Трек"}
|
||||||
|
>
|
||||||
<div className="music-track-image">
|
<div className="music-track-image">
|
||||||
<div className="music-track-icon">
|
<div className="music-track-icon">
|
||||||
<span
|
<span
|
||||||
@@ -45,22 +83,9 @@ const MusicTrack = ({
|
|||||||
music_note
|
music_note
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<img
|
<CachedImage
|
||||||
alt={item.Name ?? "Трек"}
|
alt={item.Name ?? "Трек"}
|
||||||
src={
|
src={imageUrl}
|
||||||
api &&
|
|
||||||
getImageUrlsApi(api).getItemImageUrlById(
|
|
||||||
(Object.keys(item.ImageTags ?? {}).length === 0
|
|
||||||
? item.AlbumId
|
|
||||||
: item.Id) ?? "",
|
|
||||||
"Primary",
|
|
||||||
{
|
|
||||||
quality: 70,
|
|
||||||
fillHeight: 128,
|
|
||||||
fillWidth: 128,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
style={{
|
style={{
|
||||||
width: "100%",
|
width: "100%",
|
||||||
height: "100%",
|
height: "100%",
|
||||||
@@ -71,7 +96,7 @@ const MusicTrack = ({
|
|||||||
e.currentTarget.style.opacity = "1";
|
e.currentTarget.style.opacity = "1";
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<div className="music-track-image-overlay">
|
<div className="music-track-image-overlay" data-tv-ignore>
|
||||||
<PlayButton
|
<PlayButton
|
||||||
item={item}
|
item={item}
|
||||||
itemType="Audio"
|
itemType="Audio"
|
||||||
@@ -85,7 +110,7 @@ const MusicTrack = ({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="music-track-info">
|
<div className="music-track-info" data-tv-ignore>
|
||||||
<Typography
|
<Typography
|
||||||
variant="subtitle1"
|
variant="subtitle1"
|
||||||
style={{
|
style={{
|
||||||
@@ -143,17 +168,28 @@ const MusicTrack = ({
|
|||||||
</span>
|
</span>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
{item.Album && (
|
||||||
|
<Typography
|
||||||
|
variant="caption"
|
||||||
|
className="music-track-album"
|
||||||
|
noWrap
|
||||||
|
>
|
||||||
|
{item.Album}
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<Typography variant="subtitle1">
|
<Typography variant="subtitle1">
|
||||||
{getRuntimeMusic(item.RunTimeTicks ?? 0)}
|
{getRuntimeMusic(item.RunTimeTicks ?? 0)}
|
||||||
</Typography>
|
</Typography>
|
||||||
<LikeButton
|
<div data-tv-ignore>
|
||||||
itemId={item.Id}
|
<LikeButton
|
||||||
isFavorite={item.UserData?.IsFavorite}
|
itemId={item.Id}
|
||||||
queryKey={queryKey}
|
isFavorite={item.UserData?.IsFavorite}
|
||||||
userId={userId}
|
queryKey={queryKey}
|
||||||
itemName={item.Name}
|
userId={userId}
|
||||||
/>
|
itemName={item.Name}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,52 +1,79 @@
|
|||||||
|
|
||||||
.music-track {
|
.music-track {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 4.5em 80% 1fr 1fr;
|
grid-template-columns: 52px minmax(0, 1fr) auto auto;
|
||||||
gap: 0.5em;
|
gap: 14px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-items: center;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
padding: 6px 12px;
|
||||||
|
border-radius: 12px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
&-icon {
|
transition: background-color 0.15s ease;
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
&:hover {
|
||||||
left: 0;
|
background: rgb(255 255 255 / 0.06);
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
background: rgb(255 255 255 / 0.09);
|
|
||||||
z-index: -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&-image {
|
&-image {
|
||||||
margin: 0.4em;
|
|
||||||
border-radius: $border-radius_04;
|
|
||||||
overflow: hidden;
|
|
||||||
aspect-ratio: 1;
|
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 4em;
|
width: 52px;
|
||||||
box-shadow: 0 0 10px rgb(0 0 0 / 0.2);
|
height: 52px;
|
||||||
transition: opacity $transition-time-default;
|
border-radius: 9px;
|
||||||
|
overflow: hidden;
|
||||||
|
box-shadow: 0 4px 12px rgb(0 0 0 / 0.22);
|
||||||
|
|
||||||
&-overlay {
|
&-overlay {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
inset: 0;
|
||||||
left: 0;
|
z-index: 3;
|
||||||
backdrop-filter: blur(10px);
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: rgb(8 0 31 / 0.5);
|
||||||
|
backdrop-filter: blur(8px);
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transition: opacity $transition-time-fast;
|
transition: opacity 0.15s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
> img {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&-icon {
|
||||||
|
position: absolute;
|
||||||
|
inset: 0;
|
||||||
|
z-index: 0;
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
background: linear-gradient(
|
||||||
|
145deg,
|
||||||
|
rgb(255 255 255 / 0.12),
|
||||||
|
rgb(255 255 255 / 0.04)
|
||||||
|
);
|
||||||
|
|
||||||
|
.material-symbols-rounded {
|
||||||
|
color: rgb(255 255 255 / 0.55);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&-info {
|
&-info {
|
||||||
justify-self: start;
|
display: flex;
|
||||||
&-lyrics {
|
flex-direction: column;
|
||||||
margin-right: 0.4em;
|
gap: 1px;
|
||||||
}
|
min-width: 0;
|
||||||
|
justify-self: stretch;
|
||||||
|
|
||||||
|
.MuiTypography-root,
|
||||||
|
span {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&-album {
|
||||||
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { useWindowVirtualizer } from "@tanstack/react-virtual";
|
||||||
|
import React, { useEffect, useRef, useState } from "react";
|
||||||
|
import MusicTrack from "@/components/musicTrack";
|
||||||
|
|
||||||
|
import "./musicTracksList.scss";
|
||||||
|
|
||||||
|
type MusicTracksListProps = {
|
||||||
|
items: BaseItemDto[];
|
||||||
|
userId?: string;
|
||||||
|
queryKey: string[];
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Compact, virtualized row list used for the Songs view of a music library. */
|
||||||
|
const MusicTracksList = ({ items, userId, queryKey }: MusicTracksListProps) => {
|
||||||
|
const parentRef = useRef<HTMLDivElement | null>(null);
|
||||||
|
const [scrollMargin, setScrollMargin] = useState(0);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const element = parentRef.current;
|
||||||
|
if (!element) return;
|
||||||
|
let frame = 0;
|
||||||
|
const measure = () => {
|
||||||
|
frame = requestAnimationFrame(() => setScrollMargin(element.offsetTop));
|
||||||
|
};
|
||||||
|
measure();
|
||||||
|
const observer = new ResizeObserver(measure);
|
||||||
|
observer.observe(element);
|
||||||
|
return () => {
|
||||||
|
if (frame) cancelAnimationFrame(frame);
|
||||||
|
observer.disconnect();
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const virtualizer = useWindowVirtualizer({
|
||||||
|
count: items.length,
|
||||||
|
estimateSize: () => 78,
|
||||||
|
overscan: 8,
|
||||||
|
scrollMargin,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (items.length === 0) {
|
||||||
|
return (
|
||||||
|
<div className="music-tracks-empty">
|
||||||
|
<span className="material-symbols-rounded">music_off</span>
|
||||||
|
<span>В этой библиотеке пока нет треков</span>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="music-tracks-list" ref={parentRef}>
|
||||||
|
<div className="music-tracks-head">
|
||||||
|
<span />
|
||||||
|
<span>Трек</span>
|
||||||
|
<span>Длительность</span>
|
||||||
|
<span />
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
position: "relative",
|
||||||
|
height: virtualizer.getTotalSize(),
|
||||||
|
width: "100%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{virtualizer.getVirtualItems().map((row) => {
|
||||||
|
const item = items[row.index];
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={item.Id ?? row.key}
|
||||||
|
className="music-tracks-row"
|
||||||
|
style={{
|
||||||
|
position: "absolute",
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
width: "100%",
|
||||||
|
transform: `translateY(${row.start - virtualizer.options.scrollMargin}px)`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<MusicTrack
|
||||||
|
item={item}
|
||||||
|
queryKey={queryKey}
|
||||||
|
userId={userId}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default MusicTracksList;
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
.music-tracks-list {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 1180px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding-bottom: 7rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.music-tracks-head {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 52px minmax(0, 1fr) auto auto;
|
||||||
|
gap: 14px;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0 12px 8px;
|
||||||
|
font-size: 0.72rem;
|
||||||
|
font-weight: 500;
|
||||||
|
letter-spacing: 0.08em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
color: rgb(255 255 255 / 0.4);
|
||||||
|
|
||||||
|
span:nth-child(3) {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.music-tracks-row {
|
||||||
|
will-change: transform;
|
||||||
|
}
|
||||||
|
|
||||||
|
.music-tracks-empty {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 8px;
|
||||||
|
min-height: 280px;
|
||||||
|
color: rgb(255 255 255 / 0.55);
|
||||||
|
|
||||||
|
.material-symbols-rounded {
|
||||||
|
font-size: 3rem;
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,391 @@
|
|||||||
|
import { useSnackbar } from "notistack";
|
||||||
|
import { useCallback, useEffect, useRef } from "react";
|
||||||
|
|
||||||
|
type Direction = "up" | "down" | "left" | "right";
|
||||||
|
|
||||||
|
const FOCUSABLE_SELECTOR = [
|
||||||
|
"button:not([disabled])",
|
||||||
|
"a[href]",
|
||||||
|
"input:not([disabled])",
|
||||||
|
"select:not([disabled])",
|
||||||
|
"textarea:not([disabled])",
|
||||||
|
"[tabindex]:not([tabindex='-1'])",
|
||||||
|
"[role='button']",
|
||||||
|
"[role='menuitem']",
|
||||||
|
"[role='option']",
|
||||||
|
"[role='switch']",
|
||||||
|
"[role='slider']",
|
||||||
|
"[role='tab']",
|
||||||
|
"[contenteditable='true']",
|
||||||
|
].join(",");
|
||||||
|
|
||||||
|
const isVisible = (element: HTMLElement) => {
|
||||||
|
const rect = element.getBoundingClientRect();
|
||||||
|
if (rect.width < 2 || rect.height < 2) return false;
|
||||||
|
const style = window.getComputedStyle(element);
|
||||||
|
if (style.display === "none" || style.visibility === "hidden") return false;
|
||||||
|
if (Number.parseFloat(style.opacity || "1") === 0) return false;
|
||||||
|
if (element.closest("[aria-hidden='true'], [inert]")) return false;
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const findOpenOverlay = (): HTMLElement | undefined => {
|
||||||
|
return Array.from(
|
||||||
|
document.querySelectorAll<HTMLElement>(
|
||||||
|
".MuiDialog-root, .MuiMenu-root, .MuiPopover-root, .MuiDrawer-root",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.filter(isVisible)
|
||||||
|
.pop();
|
||||||
|
};
|
||||||
|
|
||||||
|
const getScope = (): HTMLElement => {
|
||||||
|
const active = document.activeElement;
|
||||||
|
if (active instanceof HTMLElement) {
|
||||||
|
const activeScope = active.closest<HTMLElement>(
|
||||||
|
".MuiDialog-root, .MuiMenu-root, .MuiPopover-root, .MuiDrawer-root",
|
||||||
|
);
|
||||||
|
if (activeScope) return activeScope;
|
||||||
|
}
|
||||||
|
const dialogs = Array.from(
|
||||||
|
document.querySelectorAll<HTMLElement>(".MuiDialog-root"),
|
||||||
|
).filter(isVisible);
|
||||||
|
if (dialogs.length > 0) return dialogs[dialogs.length - 1];
|
||||||
|
const menus = Array.from(
|
||||||
|
document.querySelectorAll<HTMLElement>(".MuiMenu-root, .MuiPopover-root"),
|
||||||
|
).filter(isVisible);
|
||||||
|
if (menus.length > 0) return menus[menus.length - 1];
|
||||||
|
return document.body;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getCandidates = (): HTMLElement[] => {
|
||||||
|
const scope = getScope();
|
||||||
|
return Array.from(scope.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR))
|
||||||
|
.filter((element) => element !== scope)
|
||||||
|
.filter((element) => !element.closest("[data-tv-ignore]"))
|
||||||
|
.filter(isVisible)
|
||||||
|
.filter((element) => element.tabIndex >= 0 || element.hasAttribute("tabindex"));
|
||||||
|
};
|
||||||
|
|
||||||
|
const clearTvFocus = () => {
|
||||||
|
for (const element of document.querySelectorAll<HTMLElement>(
|
||||||
|
'[data-tv-focus="true"]',
|
||||||
|
)) {
|
||||||
|
element.removeAttribute("data-tv-focus");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const focusElement = (element: HTMLElement) => {
|
||||||
|
clearTvFocus();
|
||||||
|
element.setAttribute("data-tv-focus", "true");
|
||||||
|
element.focus({ preventScroll: true });
|
||||||
|
element.scrollIntoView({
|
||||||
|
block: "center",
|
||||||
|
inline: "center",
|
||||||
|
behavior: "smooth",
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const isVideoPlayer = () => window.location.pathname === "/player";
|
||||||
|
|
||||||
|
const moveFocus = (direction: Direction) => {
|
||||||
|
const candidates = getCandidates();
|
||||||
|
if (candidates.length === 0) return;
|
||||||
|
|
||||||
|
const active = document.activeElement;
|
||||||
|
const current =
|
||||||
|
active instanceof HTMLElement && active !== document.body
|
||||||
|
? active
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
if (!current || !candidates.includes(current)) {
|
||||||
|
const contentCandidates = candidates.filter(
|
||||||
|
(element) =>
|
||||||
|
!element.closest(
|
||||||
|
".appBar, .library-header, .home-header, .remote-topbar, .audio-player, .video-player, .window-chrome, .window-controls, .follow-me, .alpha-selector",
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const pool = contentCandidates.length > 0 ? contentCandidates : candidates;
|
||||||
|
const first = [...pool].sort((a, b) => {
|
||||||
|
const ar = a.getBoundingClientRect();
|
||||||
|
const br = b.getBoundingClientRect();
|
||||||
|
return ar.top - br.top || ar.left - br.left;
|
||||||
|
})[0];
|
||||||
|
if (first) focusElement(first);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentRect = current.getBoundingClientRect();
|
||||||
|
const currentX = currentRect.left + currentRect.width / 2;
|
||||||
|
const currentY = currentRect.top + currentRect.height / 2;
|
||||||
|
|
||||||
|
let best: { element: HTMLElement; score: number } | undefined;
|
||||||
|
for (const candidate of candidates) {
|
||||||
|
if (candidate === current) continue;
|
||||||
|
const rect = candidate.getBoundingClientRect();
|
||||||
|
const x = rect.left + rect.width / 2;
|
||||||
|
const y = rect.top + rect.height / 2;
|
||||||
|
const dx = x - currentX;
|
||||||
|
const dy = y - currentY;
|
||||||
|
|
||||||
|
let primary = 0;
|
||||||
|
let secondary = 0;
|
||||||
|
if (direction === "left") {
|
||||||
|
if (dx >= -4) continue;
|
||||||
|
primary = -dx;
|
||||||
|
secondary = Math.abs(dy);
|
||||||
|
} else if (direction === "right") {
|
||||||
|
if (dx <= 4) continue;
|
||||||
|
primary = dx;
|
||||||
|
secondary = Math.abs(dy);
|
||||||
|
} else if (direction === "up") {
|
||||||
|
if (dy >= -4) continue;
|
||||||
|
primary = -dy;
|
||||||
|
secondary = Math.abs(dx);
|
||||||
|
} else {
|
||||||
|
if (dy <= 4) continue;
|
||||||
|
primary = dy;
|
||||||
|
secondary = Math.abs(dx);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only move within the same visual row/column. This keeps D-pad
|
||||||
|
// navigation predictable in grids and prevents jumping to a toolbar
|
||||||
|
// when there is no neighbouring card in that direction.
|
||||||
|
const overlaps =
|
||||||
|
direction === "left" || direction === "right"
|
||||||
|
? rect.top < currentRect.bottom && rect.bottom > currentRect.top
|
||||||
|
: rect.left < currentRect.right && rect.right > currentRect.left;
|
||||||
|
if (!overlaps) continue;
|
||||||
|
const score = primary + secondary * 2.2;
|
||||||
|
if (!best || score < best.score) best = { element: candidate, score };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (best) focusElement(best.element);
|
||||||
|
};
|
||||||
|
|
||||||
|
const activateFocused = () => {
|
||||||
|
if (isVideoPlayer()) {
|
||||||
|
document.dispatchEvent(
|
||||||
|
new KeyboardEvent("keydown", { key: " ", bubbles: true }),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const active = document.activeElement;
|
||||||
|
if (active instanceof HTMLElement && active !== document.body) {
|
||||||
|
active.click();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const [first] = getCandidates();
|
||||||
|
if (first) {
|
||||||
|
focusElement(first);
|
||||||
|
first.click();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const goBack = () => {
|
||||||
|
if (isVideoPlayer()) {
|
||||||
|
document
|
||||||
|
.querySelector<HTMLElement>(
|
||||||
|
"[aria-label='Выйти из плеера'], [aria-label='Назад']",
|
||||||
|
)
|
||||||
|
?.click();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const modal = findOpenOverlay();
|
||||||
|
if (modal) {
|
||||||
|
document.dispatchEvent(
|
||||||
|
new KeyboardEvent("keydown", { key: "Escape", bubbles: true }),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const back = document.querySelector<HTMLElement>(
|
||||||
|
"[aria-label='Назад'], [aria-label='Выйти из плеера']",
|
||||||
|
);
|
||||||
|
if (back) back.click();
|
||||||
|
else window.history.back();
|
||||||
|
};
|
||||||
|
|
||||||
|
const openMenu = () => {
|
||||||
|
if (isVideoPlayer()) return;
|
||||||
|
const menu = document.querySelector<HTMLElement>(
|
||||||
|
"button[aria-label='Открыть меню']",
|
||||||
|
);
|
||||||
|
menu?.click();
|
||||||
|
};
|
||||||
|
|
||||||
|
const SpatialNavigation = () => {
|
||||||
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
|
const heldDirection = useRef<Direction | null>(null);
|
||||||
|
const nextRepeatAt = useRef(0);
|
||||||
|
const previousButtons = useRef<boolean[]>([]);
|
||||||
|
|
||||||
|
const onKeyDown = useCallback((event: KeyboardEvent) => {
|
||||||
|
if (event.defaultPrevented || event.altKey || event.metaKey || event.ctrlKey)
|
||||||
|
return;
|
||||||
|
const target =
|
||||||
|
event.target instanceof HTMLElement ? event.target : null;
|
||||||
|
if (
|
||||||
|
target?.closest(
|
||||||
|
"input, textarea, select, [contenteditable='true'], [role='slider'], .MuiSlider-root",
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
event.key === "Escape" ||
|
||||||
|
event.key === "BrowserBack" ||
|
||||||
|
event.key === "GoBack"
|
||||||
|
) {
|
||||||
|
if (findOpenOverlay()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const back = document.querySelector<HTMLElement>(
|
||||||
|
"[aria-label='Выйти из плеера'], [aria-label='Назад']",
|
||||||
|
);
|
||||||
|
if (back) {
|
||||||
|
event.preventDefault();
|
||||||
|
back.click();
|
||||||
|
} else if (event.key !== "Escape") {
|
||||||
|
window.history.back();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
target?.closest(".MuiMenu-root, .MuiPopover-root") &&
|
||||||
|
(event.key === "ArrowUp" || event.key === "ArrowDown")
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (isVideoPlayer()) return;
|
||||||
|
|
||||||
|
const directions: Record<string, Direction> = {
|
||||||
|
ArrowUp: "up",
|
||||||
|
ArrowDown: "down",
|
||||||
|
ArrowLeft: "left",
|
||||||
|
ArrowRight: "right",
|
||||||
|
};
|
||||||
|
const direction = directions[event.key];
|
||||||
|
if (!direction) return;
|
||||||
|
event.preventDefault();
|
||||||
|
moveFocus(direction);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
document.addEventListener("keydown", onKeyDown);
|
||||||
|
const onPointerDown = () => clearTvFocus();
|
||||||
|
document.addEventListener("pointerdown", onPointerDown, true);
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener("keydown", onKeyDown);
|
||||||
|
document.removeEventListener("pointerdown", onPointerDown, true);
|
||||||
|
};
|
||||||
|
}, [onKeyDown]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
let frame = 0;
|
||||||
|
let connected = false;
|
||||||
|
|
||||||
|
const getPad = () => {
|
||||||
|
const pads = navigator.getGamepads?.() ?? [];
|
||||||
|
return Array.from(pads).find((pad) => pad?.connected) ?? null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const pressed = (pad: Gamepad, index: number) =>
|
||||||
|
Boolean(pad.buttons[index]?.pressed);
|
||||||
|
|
||||||
|
const gamepadDirection = (pad: Gamepad): Direction | null => {
|
||||||
|
const up = pressed(pad, 12);
|
||||||
|
const down = pressed(pad, 13);
|
||||||
|
const left = pressed(pad, 14);
|
||||||
|
const right = pressed(pad, 15);
|
||||||
|
if (up) return "up";
|
||||||
|
if (down) return "down";
|
||||||
|
if (left) return "left";
|
||||||
|
if (right) return "right";
|
||||||
|
|
||||||
|
const x = pad.axes[0] ?? 0;
|
||||||
|
const y = pad.axes[1] ?? 0;
|
||||||
|
if (Math.abs(x) < 0.55 && Math.abs(y) < 0.55) return null;
|
||||||
|
if (Math.abs(x) > Math.abs(y)) return x < 0 ? "left" : "right";
|
||||||
|
return y < 0 ? "up" : "down";
|
||||||
|
};
|
||||||
|
|
||||||
|
const tick = (time: number) => {
|
||||||
|
const pad = getPad();
|
||||||
|
if (pad) {
|
||||||
|
if (!connected) {
|
||||||
|
connected = true;
|
||||||
|
previousButtons.current = [];
|
||||||
|
}
|
||||||
|
const direction = gamepadDirection(pad);
|
||||||
|
if (direction) {
|
||||||
|
if (heldDirection.current !== direction) {
|
||||||
|
heldDirection.current = direction;
|
||||||
|
nextRepeatAt.current = time + 320;
|
||||||
|
if (isVideoPlayer()) {
|
||||||
|
document.dispatchEvent(
|
||||||
|
new KeyboardEvent("keydown", {
|
||||||
|
key:
|
||||||
|
direction === "left"
|
||||||
|
? "ArrowLeft"
|
||||||
|
: direction === "right"
|
||||||
|
? "ArrowRight"
|
||||||
|
: direction === "up"
|
||||||
|
? "ArrowUp"
|
||||||
|
: "ArrowDown",
|
||||||
|
bubbles: true,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
moveFocus(direction);
|
||||||
|
}
|
||||||
|
} else if (time >= nextRepeatAt.current) {
|
||||||
|
nextRepeatAt.current = time + 140;
|
||||||
|
if (!isVideoPlayer()) moveFocus(direction);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
heldDirection.current = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const edge = (index: number) => {
|
||||||
|
const isPressed = pressed(pad, index);
|
||||||
|
const wasPressed = previousButtons.current[index] ?? false;
|
||||||
|
previousButtons.current[index] = isPressed;
|
||||||
|
return isPressed && !wasPressed;
|
||||||
|
};
|
||||||
|
|
||||||
|
if (edge(0)) activateFocused();
|
||||||
|
if (edge(1)) goBack();
|
||||||
|
if (edge(9)) openMenu();
|
||||||
|
} else {
|
||||||
|
connected = false;
|
||||||
|
heldDirection.current = null;
|
||||||
|
}
|
||||||
|
frame = requestAnimationFrame(tick);
|
||||||
|
};
|
||||||
|
|
||||||
|
const onConnected = (event: GamepadEvent) => {
|
||||||
|
enqueueSnackbar(`Геймпад подключён: ${event.gamepad.id}`, {
|
||||||
|
variant: "info",
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const onDisconnected = (event: GamepadEvent) => {
|
||||||
|
enqueueSnackbar(`Геймпад отключён: ${event.gamepad.id}`, {
|
||||||
|
variant: "warning",
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
window.addEventListener("gamepadconnected", onConnected);
|
||||||
|
window.addEventListener("gamepaddisconnected", onDisconnected);
|
||||||
|
frame = requestAnimationFrame(tick);
|
||||||
|
return () => {
|
||||||
|
cancelAnimationFrame(frame);
|
||||||
|
window.removeEventListener("gamepadconnected", onConnected);
|
||||||
|
window.removeEventListener("gamepaddisconnected", onDisconnected);
|
||||||
|
};
|
||||||
|
}, [enqueueSnackbar]);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SpatialNavigation;
|
||||||
@@ -11,7 +11,7 @@ export const getTypeIcon = (
|
|||||||
case "Home":
|
case "Home":
|
||||||
return <div className="material-symbols-rounded">home</div>;
|
return <div className="material-symbols-rounded">home</div>;
|
||||||
case BaseItemKind.Audio:
|
case BaseItemKind.Audio:
|
||||||
return <div className="material-symbols-rounded">mic</div>;
|
return <div className="material-symbols-rounded">music_note</div>;
|
||||||
case BaseItemKind.AudioBook:
|
case BaseItemKind.AudioBook:
|
||||||
return <div className="material-symbols-rounded">speech_to_text</div>;
|
return <div className="material-symbols-rounded">speech_to_text</div>;
|
||||||
case BaseItemKind.Book:
|
case BaseItemKind.Book:
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import RealtimeBridge from "@/components/realtime";
|
|||||||
import SplashHider from "@/components/splash";
|
import SplashHider from "@/components/splash";
|
||||||
import RemoteControlDialog from "@/components/remoteControl";
|
import RemoteControlDialog from "@/components/remoteControl";
|
||||||
import RouterLoading from "@/components/routerLoading";
|
import RouterLoading from "@/components/routerLoading";
|
||||||
|
import SpatialNavigation from "@/components/spatialNavigation";
|
||||||
import SyncPlayController from "@/components/syncPlay/controller";
|
import SyncPlayController from "@/components/syncPlay/controller";
|
||||||
import SyncPlayDialog from "@/components/syncPlay";
|
import SyncPlayDialog from "@/components/syncPlay";
|
||||||
import Search from "@/components/search";
|
import Search from "@/components/search";
|
||||||
@@ -79,6 +80,7 @@ export const Route = createRootRouteWithContext<ApiContext>()({
|
|||||||
<AudioPlayer />
|
<AudioPlayer />
|
||||||
<PlaybackSync />
|
<PlaybackSync />
|
||||||
<RealtimeBridge />
|
<RealtimeBridge />
|
||||||
|
<SpatialNavigation />
|
||||||
<FollowMe />
|
<FollowMe />
|
||||||
<OverlayScrollbar />
|
<OverlayScrollbar />
|
||||||
<Outlet />
|
<Outlet />
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { BaseItemKind, ItemSortBy } from "@jellyfin/sdk/lib/generated-client";
|
import { BaseItemKind, ItemSortBy } from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { useSuspenseQuery } from "@tanstack/react-query";
|
import { useSuspenseQuery } from "@tanstack/react-query";
|
||||||
import React, { Suspense, useEffect } from "react";
|
import React, { Suspense, useEffect } from "react";
|
||||||
|
import { ErrorBoundary } from "react-error-boundary";
|
||||||
import "./library.scss";
|
import "./library.scss";
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
@@ -65,14 +66,16 @@ function Library() {
|
|||||||
getLibraryQueryOptions(api, user?.Id, id),
|
getLibraryQueryOptions(api, user?.Id, id),
|
||||||
);
|
);
|
||||||
const updateLibrary = useLibraryStateStore((s) => s.updateLibrary);
|
const updateLibrary = useLibraryStateStore((s) => s.updateLibrary);
|
||||||
const { libraryName: storeLibraryName } = useLibraryStateStore(
|
const { libraryName: storeLibraryName, currentViewType } =
|
||||||
useShallow((s) => {
|
useLibraryStateStore(
|
||||||
const sl = s.libraries[id || ""];
|
useShallow((s) => {
|
||||||
return {
|
const sl = s.libraries[id || ""];
|
||||||
libraryName: sl?.libraryName,
|
return {
|
||||||
} as const;
|
libraryName: sl?.libraryName,
|
||||||
}),
|
currentViewType: sl?.currentViewType,
|
||||||
);
|
} as const;
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (!id || !currentLib.data) return;
|
if (!id || !currentLib.data) return;
|
||||||
@@ -107,23 +110,38 @@ function Library() {
|
|||||||
>
|
>
|
||||||
<LibraryHeader />
|
<LibraryHeader />
|
||||||
|
|
||||||
<Suspense fallback={<LibraryItemsSkeleton />}>
|
<ErrorBoundary
|
||||||
<div className="library-items">
|
fallbackRender={({ error, resetErrorBoundary }) => (
|
||||||
<LibraryItemsGrid />
|
<div className="library-load-error">
|
||||||
</div>
|
<span className="material-symbols-rounded">cloud_off</span>
|
||||||
<div
|
<h2>Не удалось загрузить библиотеку</h2>
|
||||||
style={{
|
<p>{error instanceof Error ? error.message : String(error)}</p>
|
||||||
position: "fixed",
|
<button type="button" onClick={resetErrorBoundary}>
|
||||||
right:
|
Повторить
|
||||||
currentLib.data.CollectionType === "music"
|
</button>
|
||||||
? "max(14px, calc((100vw - 1180px) / 2 + 18px))"
|
</div>
|
||||||
: 14,
|
)}
|
||||||
top: 80,
|
>
|
||||||
}}
|
<Suspense fallback={<LibraryItemsSkeleton />}>
|
||||||
>
|
<div className="library-items">
|
||||||
<AlphaSelector />
|
<LibraryItemsGrid />
|
||||||
</div>
|
</div>
|
||||||
</Suspense>
|
{currentViewType !== BaseItemKind.Audio && (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
position: "fixed",
|
||||||
|
right:
|
||||||
|
currentLib.data.CollectionType === "music"
|
||||||
|
? "max(14px, calc((100vw - 1180px) / 2 + 18px))"
|
||||||
|
: 14,
|
||||||
|
top: 80,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<AlphaSelector />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Suspense>
|
||||||
|
</ErrorBoundary>
|
||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -170,3 +170,47 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.library-load-error {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 0.6em;
|
||||||
|
min-height: 50vh;
|
||||||
|
padding: 2em;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
> .material-symbols-rounded {
|
||||||
|
font-size: 3.5rem;
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 1.4rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
max-width: 48ch;
|
||||||
|
margin: 0;
|
||||||
|
opacity: 0.65;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
overflow-wrap: anywhere;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
margin-top: 0.6em;
|
||||||
|
padding: 0.6em 1.2em;
|
||||||
|
border: 1px solid rgb(255 255 255 / 0.12);
|
||||||
|
border-radius: 999px;
|
||||||
|
background: rgb(255 255 255 / 0.08);
|
||||||
|
color: inherit;
|
||||||
|
font: inherit;
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: rgb(255 255 255 / 0.14);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+84
-102
@@ -1,14 +1,18 @@
|
|||||||
/**
|
/**
|
||||||
* Remote control for another Jellyfin client.
|
* Remote control for another Jellyfin client.
|
||||||
* Layout follows the reference player: brand bar, poster + details + round
|
* Layout follows the reference player: title bar, poster + details + round
|
||||||
* transport, a full-width timeline, and a service bar with subtitles, volume,
|
* transport, a full-width timeline, and a transparent service bar with
|
||||||
* quality and fullscreen.
|
* subtitles, volume and fullscreen.
|
||||||
*/
|
*/
|
||||||
.remote-page {
|
.remote-page {
|
||||||
--remote-accent: #{$clr-accent-default};
|
--remote-accent: #{$clr-accent-default};
|
||||||
--remote-panel: #16191f;
|
--remote-panel: #16191f;
|
||||||
--remote-chip: #1b1e25;
|
--remote-chip: rgb(255 255 255 / 0.08);
|
||||||
--remote-muted: #a9b0bb;
|
--remote-muted: rgb(255 255 255 / 0.64);
|
||||||
|
--remote-gutter: clamp(1.5rem, 2.5vw, 2rem);
|
||||||
|
--remote-surface: rgb(255 255 255 / 0.08);
|
||||||
|
--remote-surface-hover: rgb(255 255 255 / 0.14);
|
||||||
|
--remote-border: rgb(255 255 255 / 0.1);
|
||||||
|
|
||||||
position: fixed;
|
position: fixed;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
@@ -33,10 +37,35 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
gap: 24px;
|
gap: 24px;
|
||||||
height: 88px;
|
height: 58px;
|
||||||
padding: 0 32px;
|
padding: 0 var(--remote-gutter);
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
|
html.is-macos & {
|
||||||
|
padding-left: calc(var(--remote-gutter) + 64px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.MuiIconButton-root {
|
||||||
|
width: 38px;
|
||||||
|
height: 38px;
|
||||||
|
color: rgb(255 255 255 / 0.88);
|
||||||
|
background: rgb(255 255 255 / 0.08);
|
||||||
|
border: 1px solid rgb(255 255 255 / 0.1);
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
transition:
|
||||||
|
background-color 0.18s ease,
|
||||||
|
color 0.18s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: #fff;
|
||||||
|
background: rgb(255 255 255 / 0.16);
|
||||||
|
}
|
||||||
|
|
||||||
|
.material-symbols-rounded {
|
||||||
|
font-size: 1.25rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&-left,
|
&-left,
|
||||||
&-right {
|
&-right {
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -45,19 +74,6 @@
|
|||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.MuiIconButton-root {
|
|
||||||
color: #dfe3ea;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
color: #fff;
|
|
||||||
background: rgb(255 255 255 / 0.08);
|
|
||||||
}
|
|
||||||
|
|
||||||
.material-symbols-rounded {
|
|
||||||
font-size: 1.5rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&-divider {
|
&-divider {
|
||||||
width: 1px;
|
width: 1px;
|
||||||
height: 26px;
|
height: 26px;
|
||||||
@@ -65,57 +81,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.remote-brand {
|
html.is-macos .remote-topbar-right .remote-topbar-divider {
|
||||||
display: flex;
|
display: none;
|
||||||
align-items: center;
|
|
||||||
gap: 10px;
|
|
||||||
|
|
||||||
&-mark {
|
|
||||||
display: grid;
|
|
||||||
place-items: center;
|
|
||||||
width: 38px;
|
|
||||||
height: 38px;
|
|
||||||
border-radius: 50%;
|
|
||||||
background: linear-gradient(
|
|
||||||
135deg,
|
|
||||||
$clr-accent-default,
|
|
||||||
$clr-secondary-default
|
|
||||||
);
|
|
||||||
color: #fff;
|
|
||||||
|
|
||||||
.material-symbols-rounded {
|
|
||||||
font-size: 1.3rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
&-name {
|
|
||||||
font-size: 1.35rem;
|
|
||||||
font-weight: 600;
|
|
||||||
letter-spacing: -0.01em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.remote-device-chip {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
padding: 8px 12px 8px 14px;
|
|
||||||
border: 0;
|
|
||||||
border-radius: 999px;
|
|
||||||
background: var(--remote-panel);
|
|
||||||
color: #e8ebf1;
|
|
||||||
font: inherit;
|
|
||||||
font-size: 0.88rem;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: background-color 0.15s ease;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
background: #1d2028;
|
|
||||||
}
|
|
||||||
|
|
||||||
> .material-symbols-rounded {
|
|
||||||
font-size: 1.2rem;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.remote-chevron {
|
.remote-chevron {
|
||||||
@@ -136,13 +103,13 @@
|
|||||||
flex: 0 0 clamp(220px, 19vw, 280px);
|
flex: 0 0 clamp(220px, 19vw, 280px);
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
padding: clamp(0.5rem, 3vh, 2rem) 0 0 clamp(1.5rem, 4vw, 3.5rem);
|
padding: 14px 0 0 var(--remote-gutter);
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.remote-devices-title {
|
.remote-devices-title {
|
||||||
margin: 0 0 0.5em 0.6em;
|
margin: 0 0 0.5em 0.45em;
|
||||||
font-size: 0.72rem;
|
font-size: 0.72rem;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
letter-spacing: 0.2em;
|
letter-spacing: 0.2em;
|
||||||
@@ -166,8 +133,8 @@
|
|||||||
gap: 0.75em;
|
gap: 0.75em;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 0.6em 0.7em;
|
padding: 0.6em 0.7em;
|
||||||
border: 0;
|
border: 1px solid transparent;
|
||||||
border-radius: 10px;
|
border-radius: 12px;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
color: rgb(255 255 255 / 0.75);
|
color: rgb(255 255 255 / 0.75);
|
||||||
font: inherit;
|
font: inherit;
|
||||||
@@ -180,7 +147,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&.is-active {
|
&.is-active {
|
||||||
background: rgb(255 255 255 / 0.1);
|
border-color: var(--remote-border);
|
||||||
|
background: var(--remote-surface);
|
||||||
color: #fff;
|
color: #fff;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,7 +200,7 @@
|
|||||||
min-width: 0;
|
min-width: 0;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: clamp(0.5rem, 3vh, 2.5rem) clamp(1.5rem, 4vw, 3.5rem) 0;
|
padding: 0 var(--remote-gutter);
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
@@ -276,7 +244,7 @@
|
|||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
max-width: 820px;
|
max-width: 820px;
|
||||||
padding-top: clamp(0.5rem, 4vh, 3rem);
|
padding-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.remote-title {
|
.remote-title {
|
||||||
@@ -306,10 +274,12 @@
|
|||||||
|
|
||||||
.remote-chip {
|
.remote-chip {
|
||||||
padding: 7px 15px;
|
padding: 7px 15px;
|
||||||
|
border: 1px solid var(--remote-border);
|
||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
background: var(--remote-chip);
|
background: var(--remote-chip);
|
||||||
font-size: 0.95rem;
|
font-size: 0.95rem;
|
||||||
color: #dfe3ea;
|
color: #dfe3ea;
|
||||||
|
backdrop-filter: blur(12px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.remote-overview {
|
.remote-overview {
|
||||||
@@ -334,22 +304,27 @@
|
|||||||
.remote-round {
|
.remote-round {
|
||||||
display: grid;
|
display: grid;
|
||||||
place-items: center;
|
place-items: center;
|
||||||
width: clamp(64px, 6vw, 86px);
|
width: clamp(56px, 5vw, 72px);
|
||||||
height: clamp(64px, 6vw, 86px);
|
height: clamp(56px, 5vw, 72px);
|
||||||
padding: 0;
|
padding: 0;
|
||||||
border: 0;
|
border: 1px solid var(--remote-border);
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
background: var(--remote-panel);
|
background: var(--remote-surface);
|
||||||
color: #fff;
|
color: #fff;
|
||||||
|
backdrop-filter: blur(16px) saturate(150%);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transition: background-color 0.15s ease, transform 0.15s ease;
|
transition:
|
||||||
|
background-color 0.15s ease,
|
||||||
|
border-color 0.15s ease,
|
||||||
|
transform 0.15s ease;
|
||||||
|
|
||||||
.material-symbols-rounded {
|
.material-symbols-rounded {
|
||||||
font-size: clamp(1.5rem, 2vw, 2rem);
|
font-size: clamp(1.5rem, 2vw, 2rem);
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover:not(:disabled) {
|
&:hover:not(:disabled) {
|
||||||
background: #1e222b;
|
border-color: rgb(255 255 255 / 0.18);
|
||||||
|
background: var(--remote-surface-hover);
|
||||||
transform: scale(1.03);
|
transform: scale(1.03);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,17 +334,20 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&.remote-round-primary {
|
&.remote-round-primary {
|
||||||
width: clamp(74px, 7vw, 98px);
|
width: clamp(68px, 6vw, 84px);
|
||||||
height: clamp(74px, 7vw, 98px);
|
height: clamp(68px, 6vw, 84px);
|
||||||
|
border-color: transparent;
|
||||||
background: var(--remote-accent);
|
background: var(--remote-accent);
|
||||||
box-shadow: 0 10px 24px rgb(0 0 0 / 0.3);
|
box-shadow: 0 10px 28px rgb(0 0 0 / 0.28);
|
||||||
|
|
||||||
.material-symbols-rounded {
|
.material-symbols-rounded {
|
||||||
font-size: clamp(1.9rem, 2.6vw, 2.6rem);
|
font-size: clamp(1.8rem, 2.4vw, 2.4rem);
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover:not(:disabled) {
|
&:hover:not(:disabled) {
|
||||||
background: #8b70ff;
|
border-color: transparent;
|
||||||
|
background: var(--remote-accent);
|
||||||
|
filter: brightness(1.06);
|
||||||
transform: scale(1.04);
|
transform: scale(1.04);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -382,7 +360,7 @@
|
|||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 22px;
|
gap: 22px;
|
||||||
padding: clamp(0.5rem, 1.5vh, 1rem) clamp(1.5rem, 4vw, 3.5rem) 0;
|
padding: 8px var(--remote-gutter) 0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
|
||||||
.MuiSlider-root {
|
.MuiSlider-root {
|
||||||
@@ -432,11 +410,11 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
gap: 24px;
|
gap: 24px;
|
||||||
height: 72px;
|
height: 68px;
|
||||||
padding: 0 clamp(1.5rem, 4vw, 3rem);
|
padding: 0 var(--remote-gutter);
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
background: rgb(0 0 0 / 0.22);
|
background: transparent;
|
||||||
border-top: 1px solid rgb(255 255 255 / 0.06);
|
border-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.remote-bottom-item {
|
.remote-bottom-item {
|
||||||
@@ -538,7 +516,7 @@
|
|||||||
|
|
||||||
@media (max-height: 780px) {
|
@media (max-height: 780px) {
|
||||||
.remote-topbar {
|
.remote-topbar {
|
||||||
height: 72px;
|
height: 52px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.remote-title {
|
.remote-title {
|
||||||
@@ -562,17 +540,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.remote-round {
|
.remote-round {
|
||||||
width: 64px;
|
width: 54px;
|
||||||
height: 64px;
|
height: 54px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.remote-round.remote-round-primary {
|
.remote-round.remote-round-primary {
|
||||||
width: 78px;
|
width: 66px;
|
||||||
height: 78px;
|
height: 66px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.remote-bottombar {
|
.remote-bottombar {
|
||||||
height: 64px;
|
height: 58px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -586,7 +564,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.remote-bottombar {
|
.remote-bottombar {
|
||||||
height: 90px;
|
height: 76px;
|
||||||
gap: 16px;
|
gap: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -597,10 +575,14 @@
|
|||||||
|
|
||||||
@media (max-width: 820px) {
|
@media (max-width: 820px) {
|
||||||
.remote-topbar {
|
.remote-topbar {
|
||||||
height: 72px;
|
height: 52px;
|
||||||
padding: 0 16px;
|
padding: 0 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
html.is-macos .remote-topbar {
|
||||||
|
padding-left: 76px;
|
||||||
|
}
|
||||||
|
|
||||||
.remote-hero {
|
.remote-hero {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
+40
-41
@@ -12,6 +12,7 @@ import Tooltip from "@mui/material/Tooltip";
|
|||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
import { createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||||
import React, { useEffect, useMemo, useRef, useState } from "react";
|
import React, { useEffect, useMemo, useRef, useState } from "react";
|
||||||
|
import CachedImage from "@/components/cachedImage";
|
||||||
import { UserAvatarMenu } from "@/components/userAvatarMenu";
|
import { UserAvatarMenu } from "@/components/userAvatarMenu";
|
||||||
import WindowControls from "@/components/windowControls";
|
import WindowControls from "@/components/windowControls";
|
||||||
import { getRuntimeCompact } from "@/utils/date/time";
|
import { getRuntimeCompact } from "@/utils/date/time";
|
||||||
@@ -72,9 +73,10 @@ function RemotePage() {
|
|||||||
const [subtitleAnchor, setSubtitleAnchor] = useState<HTMLElement | null>(
|
const [subtitleAnchor, setSubtitleAnchor] = useState<HTMLElement | null>(
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
const [qualityAnchor, setQualityAnchor] = useState<HTMLElement | null>(null);
|
|
||||||
const [subtitleIndex, setSubtitleIndex] = useState<number>(-1);
|
const [subtitleIndex, setSubtitleIndex] = useState<number>(-1);
|
||||||
const [volumeDraft, setVolumeDraft] = useState<number | null>(null);
|
const [volumeDraft, setVolumeDraft] = useState<number | null>(null);
|
||||||
|
const [displayPosition, setDisplayPosition] = useState(0);
|
||||||
|
const [isSeeking, setIsSeeking] = useState(false);
|
||||||
const volumeTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
const volumeTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||||
|
|
||||||
const clearVolumeTimer = () => {
|
const clearVolumeTimer = () => {
|
||||||
@@ -176,10 +178,36 @@ function RemotePage() {
|
|||||||
const playState = selected?.PlayState;
|
const playState = selected?.PlayState;
|
||||||
const isPaused = playState?.IsPaused ?? true;
|
const isPaused = playState?.IsPaused ?? true;
|
||||||
const duration = nowPlaying?.RunTimeTicks ?? 0;
|
const duration = nowPlaying?.RunTimeTicks ?? 0;
|
||||||
const position = playState?.PositionTicks ?? 0;
|
|
||||||
const volume = volumeDraft ?? (playState?.VolumeLevel ?? 100) / 100;
|
const volume = volumeDraft ?? (playState?.VolumeLevel ?? 100) / 100;
|
||||||
const isMuted = playState?.IsMuted ?? false;
|
const isMuted = playState?.IsMuted ?? false;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setDisplayPosition(playState?.PositionTicks ?? 0);
|
||||||
|
setIsSeeking(false);
|
||||||
|
}, [selected?.Id]);
|
||||||
|
|
||||||
|
// Session polling is slow, so keep the timeline moving locally between
|
||||||
|
// updates. Large jumps (another client seeking) still win.
|
||||||
|
useEffect(() => {
|
||||||
|
const serverPosition = playState?.PositionTicks;
|
||||||
|
if (serverPosition == null) return;
|
||||||
|
setDisplayPosition((current) =>
|
||||||
|
Math.abs(serverPosition - current) > 2 * TICKS_PER_SECOND
|
||||||
|
? serverPosition
|
||||||
|
: current,
|
||||||
|
);
|
||||||
|
}, [playState?.PositionTicks]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isPaused || isSeeking || duration <= 0) return;
|
||||||
|
const timer = window.setInterval(() => {
|
||||||
|
setDisplayPosition((current) =>
|
||||||
|
Math.min(current + TICKS_PER_SECOND / 2, duration),
|
||||||
|
);
|
||||||
|
}, 500);
|
||||||
|
return () => window.clearInterval(timer);
|
||||||
|
}, [isPaused, isSeeking, duration, selected?.Id]);
|
||||||
|
|
||||||
const coverUrl = useMemo(() => {
|
const coverUrl = useMemo(() => {
|
||||||
if (!api || !nowPlaying) return undefined;
|
if (!api || !nowPlaying) return undefined;
|
||||||
const imageItemId = nowPlaying.AlbumId ?? nowPlaying.Id;
|
const imageItemId = nowPlaying.AlbumId ?? nowPlaying.Id;
|
||||||
@@ -228,9 +256,6 @@ function RemotePage() {
|
|||||||
channelLabel(audioStream?.Channels),
|
channelLabel(audioStream?.Channels),
|
||||||
].filter(Boolean) as string[];
|
].filter(Boolean) as string[];
|
||||||
|
|
||||||
const qualityLabel = videoStream?.Height
|
|
||||||
? `${videoStream.Height}p`
|
|
||||||
: (nowPlaying?.MediaSources?.[0]?.Name ?? "Авто");
|
|
||||||
const subtitleLabel =
|
const subtitleLabel =
|
||||||
subtitleIndex < 0
|
subtitleIndex < 0
|
||||||
? "Выкл."
|
? "Выкл."
|
||||||
@@ -271,13 +296,6 @@ function RemotePage() {
|
|||||||
>
|
>
|
||||||
<header className="remote-topbar" data-tauri-drag-region>
|
<header className="remote-topbar" data-tauri-drag-region>
|
||||||
<div className="remote-topbar-left">
|
<div className="remote-topbar-left">
|
||||||
<div className="remote-brand">
|
|
||||||
<span className="remote-brand-mark">
|
|
||||||
<span className="material-symbols-rounded">settings_remote</span>
|
|
||||||
</span>
|
|
||||||
<span className="remote-brand-name">Пульт</span>
|
|
||||||
</div>
|
|
||||||
<span className="remote-topbar-divider" />
|
|
||||||
<IconButton
|
<IconButton
|
||||||
aria-label="Главная"
|
aria-label="Главная"
|
||||||
title="Главная"
|
title="Главная"
|
||||||
@@ -366,7 +384,7 @@ function RemotePage() {
|
|||||||
<div className="remote-poster">
|
<div className="remote-poster">
|
||||||
<div className="remote-poster-frame">
|
<div className="remote-poster-frame">
|
||||||
{coverUrl ? (
|
{coverUrl ? (
|
||||||
<img src={coverUrl} alt={title ?? "Постер"} />
|
<CachedImage src={coverUrl} alt={title ?? "Постер"} />
|
||||||
) : (
|
) : (
|
||||||
<span className="material-symbols-rounded">live_tv</span>
|
<span className="material-symbols-rounded">live_tv</span>
|
||||||
)}
|
)}
|
||||||
@@ -471,16 +489,23 @@ function RemotePage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="remote-timeline">
|
<div className="remote-timeline">
|
||||||
<span className="remote-time">{formatTime(position)}</span>
|
<span className="remote-time">{formatTime(displayPosition)}</span>
|
||||||
<Slider
|
<Slider
|
||||||
className="remote-timeline-slider"
|
className="remote-timeline-slider"
|
||||||
value={Math.min(position, duration)}
|
value={Math.min(displayPosition, duration)}
|
||||||
max={duration || 1}
|
max={duration || 1}
|
||||||
step={1}
|
step={1}
|
||||||
size="small"
|
size="small"
|
||||||
aria-label="Перемотка"
|
aria-label="Перемотка"
|
||||||
|
onChange={(_, value) => {
|
||||||
|
const next = Array.isArray(value) ? value[0] : value;
|
||||||
|
setIsSeeking(true);
|
||||||
|
setDisplayPosition(next);
|
||||||
|
}}
|
||||||
onChangeCommitted={(_, value) => {
|
onChangeCommitted={(_, value) => {
|
||||||
const next = Array.isArray(value) ? value[0] : value;
|
const next = Array.isArray(value) ? value[0] : value;
|
||||||
|
setIsSeeking(false);
|
||||||
|
setDisplayPosition(next);
|
||||||
if (selected) {
|
if (selected) {
|
||||||
void command(
|
void command(
|
||||||
selected,
|
selected,
|
||||||
@@ -544,19 +569,6 @@ function RemotePage() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="remote-bottom-item"
|
|
||||||
onClick={(event) => setQualityAnchor(event.currentTarget)}
|
|
||||||
disabled={!nowPlaying}
|
|
||||||
>
|
|
||||||
<span className="material-symbols-rounded">monitor</span>
|
|
||||||
<span>Качество: {qualityLabel}</span>
|
|
||||||
<span className="material-symbols-rounded remote-chevron">
|
|
||||||
expand_more
|
|
||||||
</span>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="remote-bottom-item"
|
className="remote-bottom-item"
|
||||||
@@ -591,19 +603,6 @@ function RemotePage() {
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
))}
|
))}
|
||||||
</Menu>
|
</Menu>
|
||||||
|
|
||||||
<Menu
|
|
||||||
anchorEl={qualityAnchor}
|
|
||||||
open={Boolean(qualityAnchor)}
|
|
||||||
onClose={() => setQualityAnchor(null)}
|
|
||||||
>
|
|
||||||
<MenuItem disabled>Качество выбирает сам клиент</MenuItem>
|
|
||||||
{nowPlaying?.MediaSources?.map((source) => (
|
|
||||||
<MenuItem key={source.Id} disabled>
|
|
||||||
{source.Name ?? "Источник"}
|
|
||||||
</MenuItem>
|
|
||||||
))}
|
|
||||||
</Menu>
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -390,3 +390,17 @@ body.has-player-bar #root {
|
|||||||
a {
|
a {
|
||||||
color: $clr-accent-default;
|
color: $clr-accent-default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TV / gamepad spatial navigation focus */
|
||||||
|
[data-tv-focus="true"] {
|
||||||
|
outline: 2px solid var(--mui-palette-primary-main, #ff2d78) !important;
|
||||||
|
outline-offset: 3px;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card[data-tv-focus="true"] {
|
||||||
|
border-radius: 12px;
|
||||||
|
box-shadow:
|
||||||
|
0 0 0 2px var(--mui-palette-primary-main, #ff2d78),
|
||||||
|
0 12px 32px rgb(0 0 0 / 0.4);
|
||||||
|
}
|
||||||
Vendored
+82
@@ -0,0 +1,82 @@
|
|||||||
|
const CACHE_NAME = "blink-images-v1";
|
||||||
|
const MAX_MEMORY_ENTRIES = 400;
|
||||||
|
const MAX_CACHE_ENTRIES = 800;
|
||||||
|
|
||||||
|
const memory = new Map<string, string>();
|
||||||
|
const pending = new Map<string, Promise<string | null>>();
|
||||||
|
let cachePuts = 0;
|
||||||
|
|
||||||
|
const remember = (src: string, objectUrl: string) => {
|
||||||
|
if (memory.size >= MAX_MEMORY_ENTRIES) {
|
||||||
|
const oldest = memory.keys().next().value;
|
||||||
|
if (oldest) {
|
||||||
|
const oldUrl = memory.get(oldest);
|
||||||
|
memory.delete(oldest);
|
||||||
|
if (oldUrl) URL.revokeObjectURL(oldUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
memory.set(src, objectUrl);
|
||||||
|
};
|
||||||
|
|
||||||
|
const trimCache = async (cache: Cache) => {
|
||||||
|
cachePuts += 1;
|
||||||
|
if (cachePuts % 50 !== 0) return;
|
||||||
|
const keys = await cache.keys();
|
||||||
|
if (keys.length <= MAX_CACHE_ENTRIES) return;
|
||||||
|
for (const key of keys.slice(0, keys.length - MAX_CACHE_ENTRIES)) {
|
||||||
|
await cache.delete(key);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const cacheable = (src: string) =>
|
||||||
|
src.startsWith("http://") || src.startsWith("https://");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve an image through the WebView Cache API. The browser's HTTP cache
|
||||||
|
* only has `Cache-Control: public` for Jellyfin images (no max-age), so pages
|
||||||
|
* often refetch every poster. A named cache keeps decoded responses around.
|
||||||
|
*/
|
||||||
|
const loadImage = async (src: string): Promise<string | null> => {
|
||||||
|
if (!cacheable(src)) return null;
|
||||||
|
try {
|
||||||
|
if ("caches" in window) {
|
||||||
|
const cache = await caches.open(CACHE_NAME);
|
||||||
|
let response = await cache.match(src);
|
||||||
|
if (!response) {
|
||||||
|
response = await fetch(src, {
|
||||||
|
mode: "cors",
|
||||||
|
credentials: "omit",
|
||||||
|
});
|
||||||
|
if (!response.ok) return null;
|
||||||
|
await cache.put(src, response.clone());
|
||||||
|
void trimCache(cache);
|
||||||
|
}
|
||||||
|
const blob = await response.blob();
|
||||||
|
const objectUrl = URL.createObjectURL(blob);
|
||||||
|
remember(src, objectUrl);
|
||||||
|
return objectUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await fetch(src, {
|
||||||
|
mode: "cors",
|
||||||
|
credentials: "omit",
|
||||||
|
});
|
||||||
|
if (!response.ok) return null;
|
||||||
|
const blob = await response.blob();
|
||||||
|
const objectUrl = URL.createObjectURL(blob);
|
||||||
|
remember(src, objectUrl);
|
||||||
|
return objectUrl;
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getCachedImageUrl = (src: string): Promise<string | null> => {
|
||||||
|
const hit = memory.get(src);
|
||||||
|
if (hit) return Promise.resolve(hit);
|
||||||
|
const inFlight = pending.get(src);
|
||||||
|
if (inFlight) return inFlight;
|
||||||
|
const request = loadImage(src).finally(() => pending.delete(src));
|
||||||
|
pending.set(src, request);
|
||||||
|
return request;
|
||||||
|
};
|
||||||
@@ -92,7 +92,7 @@ export const SORT_BY_OPTIONS: Array<{
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Название трека",
|
title: "Название",
|
||||||
value: ItemSortBy.Name,
|
value: ItemSortBy.Name,
|
||||||
compatibleViewTypes: [
|
compatibleViewTypes: [
|
||||||
BaseItemKind.Audio,
|
BaseItemKind.Audio,
|
||||||
|
|||||||
@@ -17,11 +17,23 @@ export const getLibraryQueryOptions = (
|
|||||||
queryKey: ["library", "currentLib", id],
|
queryKey: ["library", "currentLib", id],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
if (!api || !userId) throw Error("API or User ID is not defined");
|
if (!api || !userId) throw Error("API or User ID is not defined");
|
||||||
const result = await getLibraryApi(api).getItem({
|
try {
|
||||||
userId: userId,
|
const result = await getLibraryApi(api).getItem({
|
||||||
itemId: id,
|
userId: userId,
|
||||||
});
|
itemId: id,
|
||||||
return result.data;
|
});
|
||||||
|
return result.data;
|
||||||
|
} catch (error) {
|
||||||
|
// Jellyfin 12 no longer returns virtual library folders from
|
||||||
|
// /Items/{id}; resolve them from the media folder list instead.
|
||||||
|
if ((error as { response?: { status?: number } })?.response?.status !== 404) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
const folders = await getLibraryApi(api).getMediaFolders();
|
||||||
|
const folder = folders.data.Items?.find((item) => item.Id === id);
|
||||||
|
if (folder) return folder;
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
enabled: !!api && !!userId,
|
enabled: !!api && !!userId,
|
||||||
});
|
});
|
||||||
@@ -174,5 +174,7 @@ export const getLibraryItemsQueryOptions = (
|
|||||||
},
|
},
|
||||||
staleTime: 5_000,
|
staleTime: 5_000,
|
||||||
gcTime: 5 * 60_000,
|
gcTime: 5 * 60_000,
|
||||||
|
retry: 1,
|
||||||
|
retryDelay: 500,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user