ommit
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
This commit is contained in:
1 parent
cbb750a413
commit
497b9a2fc5
42 files changed
+779
-188
No files matched your search
Binary file not shown.
@@ -1,6 +1,6 @@
|
|||||||
.album-track {
|
.album-track {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 2.4em minmax(0, 1fr) 4.5em 2.6em;
|
grid-template-columns: 2.4em minmax(0, 1fr) 4.5em auto;
|
||||||
gap: 1em;
|
gap: 1em;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 0.5em 1em;
|
padding: 0.5em 1em;
|
||||||
@@ -69,7 +69,9 @@
|
|||||||
|
|
||||||
&-like {
|
&-like {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 0.1em;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transition: opacity $transition-time-fast;
|
transition: opacity $transition-time-fast;
|
||||||
|
|
||||||
|
|||||||
@@ -2,19 +2,20 @@ import type {
|
|||||||
BaseItemDto,
|
BaseItemDto,
|
||||||
BaseItemDtoQueryResult,
|
BaseItemDtoQueryResult,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import React from "react";
|
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
import lyricsIcon from "../../assets/icons/lyrics.svg";
|
import React from "react";
|
||||||
import { getRuntimeMusic } from "@/utils/date/time";
|
import { getRuntimeMusic } from "@/utils/date/time";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import {
|
import {
|
||||||
generateAudioStreamUrl,
|
generateAudioStreamUrl,
|
||||||
playAudio,
|
playAudio,
|
||||||
useAudioPlayback,
|
useAudioPlayback,
|
||||||
} from "@/utils/store/audioPlayback";
|
} from "@/utils/store/audioPlayback";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import { setQueue } from "@/utils/store/queue";
|
import { setQueue } from "@/utils/store/queue";
|
||||||
|
import lyricsIcon from "../../assets/icons/lyrics.svg";
|
||||||
import LikeButton from "../buttons/likeButton";
|
import LikeButton from "../buttons/likeButton";
|
||||||
|
import RatingControl from "../buttons/ratingControl";
|
||||||
|
|
||||||
import "./albumMusicTrack.scss";
|
import "./albumMusicTrack.scss";
|
||||||
|
|
||||||
@@ -25,10 +26,17 @@ type AlbumMusicTrackProps = {
|
|||||||
*/
|
*/
|
||||||
trackIndex: number;
|
trackIndex: number;
|
||||||
musicTracks: BaseItemDtoQueryResult | null;
|
musicTracks: BaseItemDtoQueryResult | null;
|
||||||
|
/** Query key of the list this track belongs to, refreshed after a rating change. */
|
||||||
|
queryKey?: string[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function AlbumMusicTrack(props: AlbumMusicTrackProps) {
|
export default function AlbumMusicTrack(props: AlbumMusicTrackProps) {
|
||||||
const { track, musicTracks, trackIndex } = props;
|
const {
|
||||||
|
track,
|
||||||
|
musicTracks,
|
||||||
|
trackIndex,
|
||||||
|
queryKey = ["item", "musicTracks"],
|
||||||
|
} = props;
|
||||||
const [currentPlayingItem] = useAudioPlayback((state) => [state.item]);
|
const [currentPlayingItem] = useAudioPlayback((state) => [state.item]);
|
||||||
|
|
||||||
const user = useCentralStore((state) => state.currentUser);
|
const user = useCentralStore((state) => state.currentUser);
|
||||||
@@ -88,17 +96,13 @@ export default function AlbumMusicTrack(props: AlbumMusicTrackProps) {
|
|||||||
<span className="material-symbols-rounded album-track-play">
|
<span className="material-symbols-rounded album-track-play">
|
||||||
play_arrow
|
play_arrow
|
||||||
</span>
|
</span>
|
||||||
<span className="album-track-number">
|
<span className="album-track-number">{track.IndexNumber ?? "–"}</span>
|
||||||
{track.IndexNumber ?? "–"}
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="album-track-info">
|
<div className="album-track-info">
|
||||||
<span className="album-track-name">{track.Name}</span>
|
<span className="album-track-name">{track.Name}</span>
|
||||||
{(artists.length > 0 || track.HasLyrics) && (
|
{(artists.length > 0 || track.HasLyrics) && (
|
||||||
<span className="album-track-artist">
|
<span className="album-track-artist">
|
||||||
{track.HasLyrics && (
|
{track.HasLyrics && <img src={lyricsIcon} alt="Есть текст песни" />}
|
||||||
<img src={lyricsIcon} alt="Есть текст песни" />
|
|
||||||
)}
|
|
||||||
{artists.join(", ")}
|
{artists.join(", ")}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
@@ -107,10 +111,18 @@ export default function AlbumMusicTrack(props: AlbumMusicTrackProps) {
|
|||||||
{getRuntimeMusic(track.RunTimeTicks ?? 0)}
|
{getRuntimeMusic(track.RunTimeTicks ?? 0)}
|
||||||
</span>
|
</span>
|
||||||
<div className="album-track-like" onClick={(e) => e.stopPropagation()}>
|
<div className="album-track-like" onClick={(e) => e.stopPropagation()}>
|
||||||
|
<RatingControl
|
||||||
|
itemId={track.Id}
|
||||||
|
likes={track.UserData?.Likes}
|
||||||
|
queryKey={queryKey}
|
||||||
|
userId={user?.Id}
|
||||||
|
itemName={track.Name}
|
||||||
|
compact
|
||||||
|
/>
|
||||||
<LikeButton
|
<LikeButton
|
||||||
itemId={track.Id}
|
itemId={track.Id}
|
||||||
isFavorite={track.UserData?.IsFavorite}
|
isFavorite={track.UserData?.IsFavorite}
|
||||||
queryKey={["item", "musicTracks"]}
|
queryKey={queryKey}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
itemName={track.Name}
|
itemName={track.Name}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -0,0 +1,117 @@
|
|||||||
|
/* Titlebar status: a tiny spinner that resolves into check / warning. */
|
||||||
|
.app-status {
|
||||||
|
--status-accent: rgb(255 255 255 / 0.8);
|
||||||
|
|
||||||
|
position: relative;
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
width: 2.35rem;
|
||||||
|
height: 2.35rem;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
border-radius: 50%;
|
||||||
|
color: var(--status-accent);
|
||||||
|
opacity: 0;
|
||||||
|
transform: scale(0.92);
|
||||||
|
pointer-events: none;
|
||||||
|
transition:
|
||||||
|
opacity 0.18s ease,
|
||||||
|
transform 0.18s ease,
|
||||||
|
background-color 0.15s ease,
|
||||||
|
color 0.18s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-status--loading,
|
||||||
|
.app-status--success,
|
||||||
|
.app-status--warning,
|
||||||
|
.app-status--error,
|
||||||
|
.app-status--info {
|
||||||
|
opacity: 1;
|
||||||
|
transform: scale(1);
|
||||||
|
pointer-events: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Same hover language as the other titlebar icon buttons. */
|
||||||
|
.app-status--loading:hover,
|
||||||
|
.app-status--success:hover,
|
||||||
|
.app-status--warning:hover,
|
||||||
|
.app-status--error:hover,
|
||||||
|
.app-status--info:hover {
|
||||||
|
background: rgb(255 255 255 / 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-status--loading {
|
||||||
|
--status-accent: rgb(255 255 255 / 0.8);
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-status--success {
|
||||||
|
--status-accent: #65e6a3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-status--warning {
|
||||||
|
--status-accent: #ffc46b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-status--error {
|
||||||
|
--status-accent: #ff8a7a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-status--info {
|
||||||
|
--status-accent: #8fd0ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-status__icon {
|
||||||
|
display: grid;
|
||||||
|
place-items: center;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
|
.material-symbols-rounded {
|
||||||
|
font-size: 1.35rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-status__spinner {
|
||||||
|
width: 1.05rem;
|
||||||
|
height: 1.05rem;
|
||||||
|
border: 2px solid currentColor;
|
||||||
|
border-right-color: transparent;
|
||||||
|
border-radius: 50%;
|
||||||
|
animation: app-status-spin 0.8s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes app-status-spin {
|
||||||
|
to {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* On auth screens the titlebar is hidden; keep the same feedback as a plain
|
||||||
|
icon next to the window controls, without a separate badge around it. */
|
||||||
|
.app-status--floating {
|
||||||
|
position: fixed;
|
||||||
|
top: calc(10px + var(--safe-top));
|
||||||
|
right: calc(150px + var(--safe-right, 0px));
|
||||||
|
z-index: 1002;
|
||||||
|
filter: drop-shadow(0 2px 6px rgb(0 0 0 / 0.5));
|
||||||
|
}
|
||||||
|
|
||||||
|
html.is-android .app-status--floating {
|
||||||
|
right: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 900px) {
|
||||||
|
.app-status {
|
||||||
|
width: 2.15rem;
|
||||||
|
height: 2.15rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-status--floating {
|
||||||
|
top: calc(8px + var(--safe-top));
|
||||||
|
right: 12px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Notifications are rendered as the titlebar status instead of toasts. */
|
||||||
|
.notistack-SnackbarContainer {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
import { Tooltip } from "@mui/material";
|
||||||
|
import { useLocation } from "@tanstack/react-router";
|
||||||
|
import { AnimatePresence, motion } from "motion/react";
|
||||||
|
import React from "react";
|
||||||
|
import { shouldShowTitlebar } from "@/components/appTitlebar/routeVisibility";
|
||||||
|
import {
|
||||||
|
type AppStatusPhase,
|
||||||
|
useAppStatusStore,
|
||||||
|
} from "@/utils/store/appStatus";
|
||||||
|
|
||||||
|
import "./appStatus.scss";
|
||||||
|
|
||||||
|
const ICONS: Record<Exclude<AppStatusPhase, "idle" | "loading">, string> = {
|
||||||
|
success: "check",
|
||||||
|
warning: "warning",
|
||||||
|
error: "warning",
|
||||||
|
info: "info",
|
||||||
|
};
|
||||||
|
|
||||||
|
export const AppStatusIndicator = ({
|
||||||
|
floating = false,
|
||||||
|
}: {
|
||||||
|
floating?: boolean;
|
||||||
|
}) => {
|
||||||
|
const phase = useAppStatusStore((state) => state.phase);
|
||||||
|
const message = useAppStatusStore((state) => state.message);
|
||||||
|
|
||||||
|
if (phase === "idle") {
|
||||||
|
return floating ? null : (
|
||||||
|
<span className="app-status app-status--idle" aria-hidden="true" />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const body = (
|
||||||
|
<span
|
||||||
|
className={`app-status app-status--${phase}${
|
||||||
|
floating ? " app-status--floating" : ""
|
||||||
|
}`}
|
||||||
|
role="status"
|
||||||
|
aria-live="polite"
|
||||||
|
aria-label={message}
|
||||||
|
>
|
||||||
|
<AnimatePresence mode="wait" initial={false}>
|
||||||
|
<motion.span
|
||||||
|
key={phase}
|
||||||
|
className="app-status__icon"
|
||||||
|
initial={{ opacity: 0, scale: 0.55, rotate: -18 }}
|
||||||
|
animate={{ opacity: 1, scale: 1, rotate: 0 }}
|
||||||
|
exit={{ opacity: 0, scale: 0.55, rotate: 18 }}
|
||||||
|
transition={{ type: "spring", stiffness: 520, damping: 30 }}
|
||||||
|
>
|
||||||
|
{phase === "loading" ? (
|
||||||
|
<span className="app-status__spinner" />
|
||||||
|
) : (
|
||||||
|
<span className="material-symbols-rounded">{ICONS[phase]}</span>
|
||||||
|
)}
|
||||||
|
</motion.span>
|
||||||
|
</AnimatePresence>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Tooltip title={message} placement="bottom" arrow>
|
||||||
|
{body}
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Shows the indicator over players/auth screens where the titlebar is hidden. */
|
||||||
|
export const AppStatusOverlay = () => {
|
||||||
|
const { pathname } = useLocation();
|
||||||
|
if (shouldShowTitlebar(pathname)) return null;
|
||||||
|
// The video player renders the indicator inside its own OSD action pill,
|
||||||
|
// next to share / SyncPlay / settings, so no floating copy is needed.
|
||||||
|
if (pathname === "/player") return null;
|
||||||
|
return <AppStatusIndicator floating />;
|
||||||
|
};
|
||||||
@@ -2,6 +2,7 @@ import { IconButton, Tooltip, useScrollTrigger } from "@mui/material";
|
|||||||
import { Link, useLocation, useNavigate } from "@tanstack/react-router";
|
import { Link, useLocation, useNavigate } from "@tanstack/react-router";
|
||||||
import React, { useEffect, useLayoutEffect, useRef } from "react";
|
import React, { useEffect, useLayoutEffect, useRef } from "react";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
|
import { AppStatusIndicator } from "@/components/appStatus";
|
||||||
import BackButton from "@/components/buttons/backButton";
|
import BackButton from "@/components/buttons/backButton";
|
||||||
import CastButton from "@/components/buttons/castButton";
|
import CastButton from "@/components/buttons/castButton";
|
||||||
import { UserAvatarMenu } from "@/components/userAvatarMenu";
|
import { UserAvatarMenu } from "@/components/userAvatarMenu";
|
||||||
@@ -129,6 +130,7 @@ export const AppTitlebar = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="app-titlebar-actions" data-tauri-drag-region>
|
<div className="app-titlebar-actions" data-tauri-drag-region>
|
||||||
|
<AppStatusIndicator />
|
||||||
<span className="app-titlebar-cast">
|
<span className="app-titlebar-cast">
|
||||||
<CastButton
|
<CastButton
|
||||||
item={currentMedia}
|
item={currentMedia}
|
||||||
|
|||||||
@@ -28,9 +28,11 @@ export default function Backdrop() {
|
|||||||
initial={{ opacity: 0 }}
|
initial={{ opacity: 0 }}
|
||||||
animate={{ opacity: 1 }}
|
animate={{ opacity: 1 }}
|
||||||
key={hash}
|
key={hash}
|
||||||
exit={{ opacity: 0 }}
|
// Do not fade the old backdrop out: the incoming canvas fades in
|
||||||
|
// on top, otherwise the page dips through black between hashes.
|
||||||
|
exit={{ opacity: 1 }}
|
||||||
transition={{
|
transition={{
|
||||||
duration: 0.45,
|
duration: 0.8,
|
||||||
ease: "easeInOut",
|
ease: "easeInOut",
|
||||||
}}
|
}}
|
||||||
className="app-backdrop-container"
|
className="app-backdrop-container"
|
||||||
|
|||||||
@@ -142,7 +142,9 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
setCheckForQuickConnect(true);
|
setCheckForQuickConnect(true);
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
enqueueSnackbar("Не удалось запустить Quick Connect.", { variant: "error" });
|
enqueueSnackbar("Не удалось запустить Quick Connect.", {
|
||||||
|
variant: "error",
|
||||||
|
});
|
||||||
console.error(error);
|
console.error(error);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -157,7 +159,6 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
useInterval(
|
useInterval(
|
||||||
() => {
|
() => {
|
||||||
if (quickConnectSecret) {
|
if (quickConnectSecret) {
|
||||||
console.log(checkForQuickConnect);
|
|
||||||
checkQuickConnectStatus.mutate(quickConnectSecret);
|
checkQuickConnectStatus.mutate(quickConnectSecret);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -187,9 +188,7 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
: "Quick Connect недоступен"}
|
: "Quick Connect недоступен"}
|
||||||
</span>
|
</span>
|
||||||
<span className="qc-label-short">
|
<span className="qc-label-short">
|
||||||
{quickConnectEnabled.data?.data
|
{quickConnectEnabled.data?.data ? "Quick Connect" : "QC недоступен"}
|
||||||
? "Quick Connect"
|
|
||||||
: "QC недоступен"}
|
|
||||||
</span>
|
</span>
|
||||||
</LoadingButton>
|
</LoadingButton>
|
||||||
<Dialog
|
<Dialog
|
||||||
@@ -259,9 +258,17 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
|||||||
variant="body2"
|
variant="body2"
|
||||||
sx={{ mt: 2, opacity: 0.75, textAlign: "center" }}
|
sx={{ mt: 2, opacity: 0.75, textAlign: "center" }}
|
||||||
>
|
>
|
||||||
Или отсканируйте код в Blink на телефоне, чтобы подтвердить вход.
|
Или отсканируйте код в Blink на телефоне, чтобы подтвердить
|
||||||
|
вход.
|
||||||
</Typography>
|
</Typography>
|
||||||
<div style={{ marginTop: "1em", background: "#08001f", borderRadius: 12, padding: 8 }}>
|
<div
|
||||||
|
style={{
|
||||||
|
marginTop: "1em",
|
||||||
|
background: "#08001f",
|
||||||
|
borderRadius: 12,
|
||||||
|
padding: 8,
|
||||||
|
}}
|
||||||
|
>
|
||||||
<QRCodeImage
|
<QRCodeImage
|
||||||
value={buildQuickConnectDeepLink(quickConnectCode)}
|
value={buildQuickConnectDeepLink(quickConnectCode)}
|
||||||
size={180}
|
size={180}
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
.rating-control {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
|
||||||
|
.MuiIconButton-root {
|
||||||
|
padding: 0.35rem;
|
||||||
|
color: rgb(255 255 255 / 0.72);
|
||||||
|
transition:
|
||||||
|
color 150ms ease,
|
||||||
|
background-color 150ms ease,
|
||||||
|
opacity 150ms ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: #fff;
|
||||||
|
background: rgb(255 255 255 / 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
&.Mui-disabled {
|
||||||
|
color: rgb(255 255 255 / 0.25);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.material-symbols-rounded {
|
||||||
|
font-size: 1.35rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.is-compact {
|
||||||
|
.MuiIconButton-root {
|
||||||
|
padding: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.material-symbols-rounded {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,159 @@
|
|||||||
|
import { getUserDataApi } from "@jellyfin/sdk/lib/utils/api/user-data-api";
|
||||||
|
import IconButton from "@mui/material/IconButton";
|
||||||
|
import Tooltip from "@mui/material/Tooltip";
|
||||||
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||||
|
import { useSnackbar } from "notistack";
|
||||||
|
import React, { type CSSProperties } from "react";
|
||||||
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
|
|
||||||
|
import "./ratingControl.scss";
|
||||||
|
|
||||||
|
const LIKED_COLOR = "#65e6a3";
|
||||||
|
const DISLIKED_COLOR = "#ff8a7a";
|
||||||
|
|
||||||
|
type RatingControlProps = {
|
||||||
|
itemId?: string | null;
|
||||||
|
/** Jellyfin Likes: true = like, false = dislike, null/undefined = none. */
|
||||||
|
likes?: boolean | null;
|
||||||
|
queryKey?: string[];
|
||||||
|
userId?: string;
|
||||||
|
itemName?: string | null;
|
||||||
|
compact?: boolean;
|
||||||
|
/** Keep the active state monochrome (filled icon, no accent colour). */
|
||||||
|
monochrome?: boolean;
|
||||||
|
className?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thumb up / thumb down for music. This is the Jellyfin rating (`Likes`),
|
||||||
|
* separate from the favorite heart: disliking a track does not remove it
|
||||||
|
* from favorites.
|
||||||
|
*/
|
||||||
|
export default function RatingControl({
|
||||||
|
itemId,
|
||||||
|
likes,
|
||||||
|
queryKey,
|
||||||
|
userId,
|
||||||
|
itemName,
|
||||||
|
compact = false,
|
||||||
|
monochrome = false,
|
||||||
|
className,
|
||||||
|
}: RatingControlProps) {
|
||||||
|
const api = useApiInContext((state) => state.api);
|
||||||
|
const queryClient = useQueryClient();
|
||||||
|
const { enqueueSnackbar } = useSnackbar();
|
||||||
|
const [rating, setRating] = React.useState<boolean | null | undefined>(likes);
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
setRating(likes);
|
||||||
|
}, [likes]);
|
||||||
|
|
||||||
|
const mutation = useMutation({
|
||||||
|
mutationKey: ["ratingControl", itemId],
|
||||||
|
mutationFn: async (next: boolean | null) => {
|
||||||
|
if (!api || !itemId || !userId) return null;
|
||||||
|
const userDataApi = getUserDataApi(api);
|
||||||
|
const response =
|
||||||
|
next === null
|
||||||
|
? await userDataApi.deleteUserItemRating({ itemId, userId })
|
||||||
|
: await userDataApi.updateUserItemRating({
|
||||||
|
itemId,
|
||||||
|
userId,
|
||||||
|
likes: next,
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
|
onSuccess: (data) => {
|
||||||
|
if (data) setRating(data.Likes ?? null);
|
||||||
|
},
|
||||||
|
onError: () => {
|
||||||
|
setRating(likes);
|
||||||
|
enqueueSnackbar(
|
||||||
|
`Не удалось обновить оценку${itemName ? ` «${itemName}»` : ""}`,
|
||||||
|
{ variant: "error" },
|
||||||
|
);
|
||||||
|
},
|
||||||
|
onSettled: async () => {
|
||||||
|
if (queryKey) {
|
||||||
|
await queryClient.invalidateQueries({ queryKey });
|
||||||
|
}
|
||||||
|
// Keep item details (full player, floating bar, headers) in sync.
|
||||||
|
if (itemId) {
|
||||||
|
await queryClient.invalidateQueries({ queryKey: ["item", itemId] });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const updateRating = (next: boolean) => {
|
||||||
|
if (!api || !itemId || !userId || mutation.isPending) return;
|
||||||
|
const value = rating === next ? null : next;
|
||||||
|
setRating(value);
|
||||||
|
mutation.mutate(value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const disabled = !api || !itemId || !userId;
|
||||||
|
const isLiked = rating === true;
|
||||||
|
const isDisliked = rating === false;
|
||||||
|
const size = compact ? "small" : "medium";
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={`rating-control${compact ? " is-compact" : ""}${
|
||||||
|
className ? ` ${className}` : ""
|
||||||
|
}`}
|
||||||
|
onClick={(event) => event.stopPropagation()}
|
||||||
|
onKeyDown={(event) => event.stopPropagation()}
|
||||||
|
>
|
||||||
|
<Tooltip title={isLiked ? "Убрать оценку «Нравится»" : "Нравится"}>
|
||||||
|
<span>
|
||||||
|
<IconButton
|
||||||
|
size={size}
|
||||||
|
disabled={disabled || mutation.isPending}
|
||||||
|
aria-label="Нравится"
|
||||||
|
aria-pressed={isLiked}
|
||||||
|
onClick={() => updateRating(true)}
|
||||||
|
sx={{ opacity: mutation.isPending ? 0.5 : 1 }}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="material-symbols-rounded"
|
||||||
|
style={
|
||||||
|
{
|
||||||
|
"--fill": isLiked ? 1 : 0,
|
||||||
|
color: isLiked && !monochrome ? LIKED_COLOR : undefined,
|
||||||
|
} as CSSProperties
|
||||||
|
}
|
||||||
|
>
|
||||||
|
thumb_up
|
||||||
|
</span>
|
||||||
|
</IconButton>
|
||||||
|
</span>
|
||||||
|
</Tooltip>
|
||||||
|
<Tooltip
|
||||||
|
title={isDisliked ? "Убрать оценку «Не нравится»" : "Не нравится"}
|
||||||
|
>
|
||||||
|
<span>
|
||||||
|
<IconButton
|
||||||
|
size={size}
|
||||||
|
disabled={disabled || mutation.isPending}
|
||||||
|
aria-label="Не нравится"
|
||||||
|
aria-pressed={isDisliked}
|
||||||
|
onClick={() => updateRating(false)}
|
||||||
|
sx={{ opacity: mutation.isPending ? 0.5 : 1 }}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className="material-symbols-rounded"
|
||||||
|
style={
|
||||||
|
{
|
||||||
|
"--fill": isDisliked ? 1 : 0,
|
||||||
|
color: isDisliked && !monochrome ? DISLIKED_COLOR : undefined,
|
||||||
|
} as CSSProperties
|
||||||
|
}
|
||||||
|
>
|
||||||
|
thumb_down
|
||||||
|
</span>
|
||||||
|
</IconButton>
|
||||||
|
</span>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
import React, { useCallback, useEffect, useState } from "react";
|
|
||||||
import type { Api } from "@jellyfin/sdk";
|
import type { Api } from "@jellyfin/sdk";
|
||||||
import {
|
import {
|
||||||
type BaseItemDto,
|
type BaseItemDto,
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { AnimatePresence } from "motion/react";
|
||||||
|
import React, { useCallback, useEffect, useState } from "react";
|
||||||
import { useCarouselStore } from "../../utils/store/carousel";
|
import { useCarouselStore } from "../../utils/store/carousel";
|
||||||
import "./carousel.scss";
|
import "./carousel.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 { resolveItemImage } from "@/utils/methods/itemImages";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
@@ -17,10 +19,7 @@ const AUTOPLAY_MS = 9000;
|
|||||||
const MemoizedCarouselSlide = React.memo(CarouselSlide);
|
const MemoizedCarouselSlide = React.memo(CarouselSlide);
|
||||||
|
|
||||||
/** Wide artwork for the trending rail, falling back through the item's images. */
|
/** Wide artwork for the trending rail, falling back through the item's images. */
|
||||||
const trendingImageUrl = (
|
const trendingImageUrl = (api: Api, item: BaseItemDto): string | undefined => {
|
||||||
api: Api,
|
|
||||||
item: BaseItemDto,
|
|
||||||
): string | undefined => {
|
|
||||||
const image = resolveItemImage(item, "Thumb");
|
const image = resolveItemImage(item, "Thumb");
|
||||||
if (!image) return undefined;
|
if (!image) return undefined;
|
||||||
return getImageUrlsApi(api).getItemImageUrlById(
|
return getImageUrlsApi(api).getItemImageUrlById(
|
||||||
@@ -101,7 +100,9 @@ const Carousel = ({
|
|||||||
onMouseEnter={() => setIsPaused(true)}
|
onMouseEnter={() => setIsPaused(true)}
|
||||||
onMouseLeave={() => setIsPaused(false)}
|
onMouseLeave={() => setIsPaused(false)}
|
||||||
>
|
>
|
||||||
|
<AnimatePresence initial={false} mode="sync">
|
||||||
<MemoizedCarouselSlide key={currentItem.Id} item={currentItem} />
|
<MemoizedCarouselSlide key={currentItem.Id} item={currentItem} />
|
||||||
|
</AnimatePresence>
|
||||||
|
|
||||||
{total > 1 && (
|
{total > 1 && (
|
||||||
<button
|
<button
|
||||||
@@ -145,20 +146,19 @@ const Carousel = ({
|
|||||||
onClick={() => goTo(index)}
|
onClick={() => goTo(index)}
|
||||||
aria-label={item.Name ?? "Рекомендуемое"}
|
aria-label={item.Name ?? "Рекомендуемое"}
|
||||||
>
|
>
|
||||||
{imageUrl ? (
|
<CachedImage
|
||||||
<img
|
|
||||||
src={imageUrl}
|
src={imageUrl}
|
||||||
alt=""
|
alt=""
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
decoding="async"
|
decoding="async"
|
||||||
/>
|
fallback={
|
||||||
) : (
|
|
||||||
<div className="cinema-trending-placeholder">
|
<div className="cinema-trending-placeholder">
|
||||||
<span className="material-symbols-rounded">
|
<span className="material-symbols-rounded">
|
||||||
{ item.Type === BaseItemKind.Series ? "tv" : "movie" }
|
{item.Type === BaseItemKind.Series ? "tv" : "movie"}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
}
|
||||||
|
/>
|
||||||
<span className="cinema-trending-chip">
|
<span className="cinema-trending-chip">
|
||||||
{trendingLabel(item)}
|
{trendingLabel(item)}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -7,27 +7,27 @@ import Chip from "@mui/material/Chip";
|
|||||||
import { green, red, yellow } from "@mui/material/colors";
|
import { green, red, yellow } from "@mui/material/colors";
|
||||||
import Stack from "@mui/material/Stack";
|
import Stack from "@mui/material/Stack";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
import { useNavigate } from "@tanstack/react-router";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { useNavigate } from "@tanstack/react-router";
|
||||||
import { motion, type Variants } from "motion/react";
|
import { motion, type Variants } from "motion/react";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import CachedImage from "@/components/cachedImage";
|
||||||
import { endsAt, getRuntime } from "@/utils/date/time";
|
import { endsAt, getRuntime } from "@/utils/date/time";
|
||||||
import {
|
import {
|
||||||
getHeroPosterUrl,
|
getHeroPosterUrl,
|
||||||
getItemImagesQueryOptions,
|
getItemImagesQueryOptions,
|
||||||
resolveHeroArtwork,
|
resolveHeroArtwork,
|
||||||
} from "@/utils/methods/heroArtwork";
|
} from "@/utils/methods/heroArtwork";
|
||||||
import CachedImage from "@/components/cachedImage";
|
import { getItemLinkOptions } from "@/utils/navigation/itemLink";
|
||||||
import BlurhashCanvas from "../blurhash-canvas";
|
|
||||||
|
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useCarouselStore } from "@/utils/store/carousel";
|
import { useCarouselStore } from "@/utils/store/carousel";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
|
import BlurhashCanvas from "../blurhash-canvas";
|
||||||
import LikeButton from "../buttons/likeButton";
|
import LikeButton from "../buttons/likeButton";
|
||||||
import MarkPlayedButton from "../buttons/markPlayedButton";
|
import MarkPlayedButton from "../buttons/markPlayedButton";
|
||||||
import PlayButton from "../buttons/playButton";
|
import PlayButton from "../buttons/playButton";
|
||||||
import { getTypeIcon } from "../utils/iconsCollection";
|
import { getTypeIcon } from "../utils/iconsCollection";
|
||||||
import { getItemLinkOptions } from "@/utils/navigation/itemLink";
|
|
||||||
|
|
||||||
const MotionTypography = motion.create(Typography);
|
const MotionTypography = motion.create(Typography);
|
||||||
const MotionStack = motion.create(Stack);
|
const MotionStack = motion.create(Stack);
|
||||||
@@ -79,14 +79,17 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="hero-carousel-slide">
|
|
||||||
<motion.div
|
<motion.div
|
||||||
className="hero-carousel-background-container"
|
className="hero-carousel-slide"
|
||||||
initial={{ opacity: 1 }}
|
initial={{ opacity: 0 }}
|
||||||
animate={{ opacity: 1 }}
|
animate={{ opacity: 1 }}
|
||||||
exit={{ opacity: 0 }}
|
// Keep the previous slide fully visible underneath while the next
|
||||||
transition={{ duration: 0.4, ease: "easeInOut" }}
|
// one fades in. The text inside fades out on its own, so the
|
||||||
|
// background crossfades without dipping to black between slides.
|
||||||
|
exit={{ opacity: 1 }}
|
||||||
|
transition={{ duration: 0.8, ease: [0.2, 0, 0, 1] }}
|
||||||
>
|
>
|
||||||
|
<div className="hero-carousel-background-container">
|
||||||
{heroArtwork?.blurhash && (
|
{heroArtwork?.blurhash && (
|
||||||
<BlurhashCanvas
|
<BlurhashCanvas
|
||||||
blurhashString={heroArtwork.blurhash}
|
blurhashString={heroArtwork.blurhash}
|
||||||
@@ -118,7 +121,7 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
loading="eager"
|
loading="eager"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</motion.div>
|
</div>
|
||||||
<motion.div
|
<motion.div
|
||||||
className="hero-carousel-detail"
|
className="hero-carousel-detail"
|
||||||
initial="initial"
|
initial="initial"
|
||||||
@@ -341,7 +344,7 @@ const CarouselSlide = ({ item }: { item: BaseItemDto }) => {
|
|||||||
</Stack>
|
</Stack>
|
||||||
</MotionStack>
|
</MotionStack>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
</div>
|
</motion.div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -9,13 +9,14 @@ import {
|
|||||||
} from "../../utils/store/audioPlayback";
|
} 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 RatingControl from "../buttons/ratingControl";
|
||||||
import "./musicTrack.scss";
|
import "./musicTrack.scss";
|
||||||
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { Link } from "@tanstack/react-router";
|
||||||
import CachedImage from "@/components/cachedImage";
|
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";
|
||||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import { Link } from "@tanstack/react-router";
|
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import { setQueue } from "@/utils/store/queue";
|
import { setQueue } from "@/utils/store/queue";
|
||||||
import lyrics_icon from "../../assets/icons/lyrics.svg";
|
import lyrics_icon from "../../assets/icons/lyrics.svg";
|
||||||
@@ -59,10 +60,7 @@ const MusicTrack = ({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (queue && queue.length > 0) {
|
if (queue && queue.length > 0) {
|
||||||
const index = Math.max(
|
const index = Math.max(0, Math.min(queueIndex ?? 0, queue.length - 1));
|
||||||
0,
|
|
||||||
Math.min(queueIndex ?? 0, queue.length - 1),
|
|
||||||
);
|
|
||||||
const selected = queue[index];
|
const selected = queue[index];
|
||||||
if (!selected?.Id) return;
|
if (!selected?.Id) return;
|
||||||
playAudio(
|
playAudio(
|
||||||
@@ -218,11 +216,7 @@ const MusicTrack = ({
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
{item.Album && (
|
{item.Album && (
|
||||||
<Typography
|
<Typography variant="caption" className="music-track-album" noWrap>
|
||||||
variant="caption"
|
|
||||||
className="music-track-album"
|
|
||||||
noWrap
|
|
||||||
>
|
|
||||||
{item.Album}
|
{item.Album}
|
||||||
</Typography>
|
</Typography>
|
||||||
)}
|
)}
|
||||||
@@ -230,7 +224,15 @@ const MusicTrack = ({
|
|||||||
<Typography variant="subtitle1">
|
<Typography variant="subtitle1">
|
||||||
{getRuntimeMusic(item.RunTimeTicks ?? 0)}
|
{getRuntimeMusic(item.RunTimeTicks ?? 0)}
|
||||||
</Typography>
|
</Typography>
|
||||||
<div data-tv-ignore>
|
<div className="music-track-actions" data-tv-ignore>
|
||||||
|
<RatingControl
|
||||||
|
itemId={item.Id}
|
||||||
|
likes={item.UserData?.Likes}
|
||||||
|
queryKey={queryKey}
|
||||||
|
userId={userId}
|
||||||
|
itemName={item.Name}
|
||||||
|
compact
|
||||||
|
/>
|
||||||
<LikeButton
|
<LikeButton
|
||||||
itemId={item.Id}
|
itemId={item.Id}
|
||||||
isFavorite={item.UserData?.IsFavorite}
|
isFavorite={item.UserData?.IsFavorite}
|
||||||
|
|||||||
@@ -76,6 +76,12 @@
|
|||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&-actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.15rem;
|
||||||
|
}
|
||||||
|
|
||||||
&-play-icon {
|
&-play-icon {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
font-size: 1.8rem;
|
font-size: 1.8rem;
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import { type CustomContentProps, useSnackbar } from "notistack";
|
||||||
|
import React, { forwardRef, useEffect } from "react";
|
||||||
|
import { useAppStatusStore } from "@/utils/store/appStatus";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notistack is kept as the app-wide notification bus, but nothing is rendered
|
||||||
|
* in the corner anymore: every message becomes a transient status in the
|
||||||
|
* titlebar (spinner → check / warning). The bridge closes its snackbar
|
||||||
|
* immediately so the hidden queue never builds up.
|
||||||
|
*
|
||||||
|
* Notistack requires custom content to forward a ref, even when it renders no
|
||||||
|
* visible toast. Without it the transition throws and the router shows the
|
||||||
|
* error page for a moment.
|
||||||
|
*/
|
||||||
|
const NotificationBridge = forwardRef<HTMLSpanElement, CustomContentProps>(
|
||||||
|
({ id, message, variant }, ref) => {
|
||||||
|
const { closeSnackbar } = useSnackbar();
|
||||||
|
const notify = useAppStatusStore((state) => state.notify);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
notify(variant, message);
|
||||||
|
closeSnackbar(id);
|
||||||
|
}, [closeSnackbar, id, message, notify, variant]);
|
||||||
|
|
||||||
|
return <span ref={ref} hidden aria-hidden="true" />;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
NotificationBridge.displayName = "NotificationBridge";
|
||||||
|
|
||||||
|
export default NotificationBridge;
|
||||||
@@ -5,6 +5,7 @@ import { useQuery } from "@tanstack/react-query";
|
|||||||
import { Link } from "@tanstack/react-router";
|
import { Link } from "@tanstack/react-router";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import LikeButton from "@/components/buttons/likeButton";
|
import LikeButton from "@/components/buttons/likeButton";
|
||||||
|
import RatingControl from "@/components/buttons/ratingControl";
|
||||||
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
import getImageUrlsApi from "@/utils/methods/getImageUrlsApi";
|
||||||
import { getItemQueryOptions } from "@/utils/queries/items";
|
import { getItemQueryOptions } from "@/utils/queries/items";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
@@ -92,6 +93,14 @@ const PlayerInfo = ({ item, api, onOpen }: PlayerInfoProps) => {
|
|||||||
queryKey={["item", item.Id ?? ""]}
|
queryKey={["item", item.Id ?? ""]}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
|
<RatingControl
|
||||||
|
itemId={item.Id}
|
||||||
|
likes={itemDetails.data?.UserData?.Likes ?? item.UserData?.Likes}
|
||||||
|
queryKey={["item", item.Id ?? ""]}
|
||||||
|
userId={user?.Id}
|
||||||
|
itemName={item.Name}
|
||||||
|
compact
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,11 +10,13 @@ import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
|||||||
import IconButton from "@mui/material/IconButton";
|
import IconButton from "@mui/material/IconButton";
|
||||||
import Tooltip from "@mui/material/Tooltip";
|
import Tooltip from "@mui/material/Tooltip";
|
||||||
import Typography from "@mui/material/Typography";
|
import Typography from "@mui/material/Typography";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { useLocation, useNavigate } from "@tanstack/react-router";
|
import { useLocation, useNavigate } from "@tanstack/react-router";
|
||||||
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
import { AnimatePresence, motion, useReducedMotion } from "motion/react";
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
import React, { type SyntheticEvent, useEffect, useRef, useState } from "react";
|
import React, { type SyntheticEvent, useEffect, useRef, useState } from "react";
|
||||||
import LikeButton from "@/components/buttons/likeButton";
|
import LikeButton from "@/components/buttons/likeButton";
|
||||||
|
import RatingControl from "@/components/buttons/ratingControl";
|
||||||
import { secToTicks, ticksToSec } from "@/utils/date/time";
|
import { secToTicks, ticksToSec } from "@/utils/date/time";
|
||||||
import {
|
import {
|
||||||
beginAudioPlaybackReport,
|
beginAudioPlaybackReport,
|
||||||
@@ -29,6 +31,7 @@ import {
|
|||||||
import getImageUrlsApi, {
|
import getImageUrlsApi, {
|
||||||
getPlayerCoverUrl,
|
getPlayerCoverUrl,
|
||||||
} from "@/utils/methods/getImageUrlsApi";
|
} from "@/utils/methods/getImageUrlsApi";
|
||||||
|
import { getItemQueryOptions } from "@/utils/queries/items";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import {
|
import {
|
||||||
setAudioPlaying,
|
setAudioPlaying,
|
||||||
@@ -151,6 +154,12 @@ const AudioPlayer = () => {
|
|||||||
|
|
||||||
const activeItem: BaseItemDto | undefined | null =
|
const activeItem: BaseItemDto | undefined | null =
|
||||||
remote?.NowPlayingItem ?? item;
|
remote?.NowPlayingItem ?? item;
|
||||||
|
// Fresh user data, so rating and favourite set elsewhere (full player,
|
||||||
|
// another list) are reflected in the bar without a reload.
|
||||||
|
const activeItemDetails = useQuery({
|
||||||
|
...getItemQueryOptions(activeItem?.Id ?? "", api, user?.Id),
|
||||||
|
enabled: Boolean(activeItem?.Id && api && user?.Id),
|
||||||
|
});
|
||||||
const artists = activeItem?.ArtistItems?.length
|
const artists = activeItem?.ArtistItems?.length
|
||||||
? activeItem.ArtistItems
|
? activeItem.ArtistItems
|
||||||
: (activeItem?.AlbumArtists ?? []);
|
: (activeItem?.AlbumArtists ?? []);
|
||||||
@@ -632,11 +641,28 @@ const AudioPlayer = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="media-bar-right">
|
<div className="media-bar-right">
|
||||||
|
{activeItem?.Id && (
|
||||||
|
<RatingControl
|
||||||
|
itemId={activeItem.Id}
|
||||||
|
likes={
|
||||||
|
activeItemDetails.data?.UserData?.Likes ??
|
||||||
|
activeItem.UserData?.Likes
|
||||||
|
}
|
||||||
|
queryKey={["item", activeItem.Id]}
|
||||||
|
userId={user?.Id}
|
||||||
|
itemName={activeItem.Name}
|
||||||
|
compact
|
||||||
|
monochrome
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<span className="media-bar-like">
|
<span className="media-bar-like">
|
||||||
<LikeButton
|
<LikeButton
|
||||||
itemId={activeItem?.Id ?? undefined}
|
itemId={activeItem?.Id ?? undefined}
|
||||||
itemName={activeItem?.Name}
|
itemName={activeItem?.Name}
|
||||||
isFavorite={activeItem?.UserData?.IsFavorite}
|
isFavorite={
|
||||||
|
activeItemDetails.data?.UserData?.IsFavorite ??
|
||||||
|
activeItem?.UserData?.IsFavorite
|
||||||
|
}
|
||||||
queryKey={["item", activeItem?.Id ?? ""]}
|
queryKey={["item", activeItem?.Id ?? ""]}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import React, {
|
|||||||
useState,
|
useState,
|
||||||
} from "react";
|
} from "react";
|
||||||
import { useShallow } from "zustand/shallow";
|
import { useShallow } from "zustand/shallow";
|
||||||
|
import { AppStatusIndicator } from "@/components/appStatus";
|
||||||
import CastButton from "@/components/buttons/castButton";
|
import CastButton from "@/components/buttons/castButton";
|
||||||
import PlayNextButton from "@/components/buttons/playNextButton";
|
import PlayNextButton from "@/components/buttons/playNextButton";
|
||||||
import PlayPreviousButton from "@/components/buttons/playPreviousButtom";
|
import PlayPreviousButton from "@/components/buttons/playPreviousButtom";
|
||||||
@@ -20,8 +21,8 @@ import { secToTicks, ticksToSec } from "@/utils/date/time";
|
|||||||
import { buildPlayDeepLink } from "@/utils/deepLinks";
|
import { buildPlayDeepLink } from "@/utils/deepLinks";
|
||||||
import { openSyncPlayDialog } from "@/utils/methods/syncPlay";
|
import { openSyncPlayDialog } from "@/utils/methods/syncPlay";
|
||||||
import { useApiInContext } from "@/utils/store/api";
|
import { useApiInContext } from "@/utils/store/api";
|
||||||
import { useShareStore } from "@/utils/store/share";
|
|
||||||
import { usePlaybackStore } from "@/utils/store/playback";
|
import { usePlaybackStore } from "@/utils/store/playback";
|
||||||
|
import { useShareStore } from "@/utils/store/share";
|
||||||
import useSyncPlayback from "@/utils/store/syncPlayback";
|
import useSyncPlayback from "@/utils/store/syncPlayback";
|
||||||
import type { VideoFitMode } from "@/utils/types/videoFitMode";
|
import type { VideoFitMode } from "@/utils/types/videoFitMode";
|
||||||
import CaptionsButton from "./buttons/CaptionsButton";
|
import CaptionsButton from "./buttons/CaptionsButton";
|
||||||
@@ -38,8 +39,7 @@ import EndsAtDisplay from "./EndsAtDisplay";
|
|||||||
import VideoPlayerSettingsMenu from "./settingsMenu";
|
import VideoPlayerSettingsMenu from "./settingsMenu";
|
||||||
|
|
||||||
import "./controls.scss";
|
import "./controls.scss";
|
||||||
import { clearQueue } from "@/utils/store/queue";
|
import useQueue, { clearQueue } from "@/utils/store/queue";
|
||||||
import useQueue from "@/utils/store/queue";
|
|
||||||
import ProgressDisplay from "./ProgressDisplay";
|
import ProgressDisplay from "./ProgressDisplay";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -280,6 +280,7 @@ const VideoPlayerControls = ({
|
|||||||
>
|
>
|
||||||
<span className="material-symbols-rounded">groups</span>
|
<span className="material-symbols-rounded">groups</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
<AppStatusIndicator />
|
||||||
<IconButton
|
<IconButton
|
||||||
onClick={(e) => setSettingsMenuRef(e.currentTarget)}
|
onClick={(e) => setSettingsMenuRef(e.currentTarget)}
|
||||||
aria-label="Настройки плеера"
|
aria-label="Настройки плеера"
|
||||||
@@ -394,7 +395,11 @@ const VideoPlayerControls = ({
|
|||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
title={syncThisVideo ? "Остановить синхронизацию" : "Синхронизация воспроизведения"}
|
title={
|
||||||
|
syncThisVideo
|
||||||
|
? "Остановить синхронизацию"
|
||||||
|
: "Синхронизация воспроизведения"
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<IconButton
|
<IconButton
|
||||||
aria-label="Синхронизация воспроизведения"
|
aria-label="Синхронизация воспроизведения"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
GeneralCommandType,
|
GeneralCommandType,
|
||||||
MediaType,
|
MediaType,
|
||||||
PlayCommand,
|
type PlayCommand,
|
||||||
PlaystateCommand,
|
PlaystateCommand,
|
||||||
} from "@jellyfin/sdk/lib/generated-client";
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
import { getSessionApi } from "@jellyfin/sdk/lib/utils/api/session-api";
|
||||||
@@ -236,7 +236,7 @@ const RealtimeBridge = () => {
|
|||||||
window.history.back();
|
window.history.back();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.info("Unhandled remote command", name, args);
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -249,11 +249,8 @@ const RealtimeBridge = () => {
|
|||||||
PlayCommand?: PlayCommand;
|
PlayCommand?: PlayCommand;
|
||||||
}) => {
|
}) => {
|
||||||
if (!play?.ItemIds?.length || !userId) return;
|
if (!play?.ItemIds?.length || !userId) return;
|
||||||
if (play.PlayCommand && play.PlayCommand !== PlayCommand.PlayNow) {
|
|
||||||
// PlayNext/PlayLast are uncommon from a remote; behave like PlayNow
|
// PlayNext/PlayLast are uncommon from a remote; behave like PlayNow
|
||||||
// instead of silently ignoring the user's intent.
|
// instead of silently ignoring the user's intent.
|
||||||
console.info("Remote play command", play.PlayCommand);
|
|
||||||
}
|
|
||||||
startPlaybackFromIds(api, userId, play.ItemIds, {
|
startPlaybackFromIds(api, userId, play.ItemIds, {
|
||||||
startIndex: play.StartIndex ?? 0,
|
startIndex: play.StartIndex ?? 0,
|
||||||
startPositionTicks: play.StartPositionTicks ?? 0,
|
startPositionTicks: play.StartPositionTicks ?? 0,
|
||||||
|
|||||||
@@ -150,7 +150,11 @@ const Search = () => {
|
|||||||
useSearchStore.getState().toggleSearchDialog();
|
useSearchStore.getState().toggleSearchDialog();
|
||||||
}
|
}
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
|
// HMR can leave the OS shortcut registered while this module is
|
||||||
|
// reloaded; that is not an application failure.
|
||||||
|
if (!String(error).toLowerCase().includes("already registered")) {
|
||||||
console.warn("Global search shortcut is unavailable", error);
|
console.warn("Global search shortcut is unavailable", error);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ export const UserAvatarMenu = () => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleLogout = useCallback(async () => {
|
const handleLogout = useCallback(async () => {
|
||||||
console.log("Logging out user...");
|
|
||||||
await api?.logout();
|
await api?.logout();
|
||||||
createApi(api?.basePath ?? "", undefined);
|
createApi(api?.basePath ?? "", undefined);
|
||||||
resetCurrentUser();
|
resetCurrentUser();
|
||||||
|
|||||||
+4
-18
@@ -4,18 +4,14 @@ import React, { useEffect } from "react";
|
|||||||
import ReactDOM from "react-dom/client";
|
import ReactDOM from "react-dom/client";
|
||||||
// Import the generated route tree
|
// Import the generated route tree
|
||||||
import { routeTree } from "./routeTree.gen";
|
import { routeTree } from "./routeTree.gen";
|
||||||
import {
|
|
||||||
ApiProvider,
|
|
||||||
initializeApi,
|
|
||||||
useApiInContext,
|
|
||||||
} from "./utils/store/api";
|
|
||||||
import { CentralProvider, useCentralStore } from "./utils/store/central";
|
|
||||||
import {
|
import {
|
||||||
clearPersistedQueryCache,
|
clearPersistedQueryCache,
|
||||||
persistQueryCache,
|
persistQueryCache,
|
||||||
restoreQueryCache,
|
restoreQueryCache,
|
||||||
} from "./utils/queryCachePersistence";
|
} from "./utils/queryCachePersistence";
|
||||||
import { delUser } from "./utils/storage/user";
|
import { delUser } from "./utils/storage/user";
|
||||||
|
import { ApiProvider, initializeApi, useApiInContext } from "./utils/store/api";
|
||||||
|
import { CentralProvider, useCentralStore } from "./utils/store/central";
|
||||||
|
|
||||||
const queryClient = new QueryClient({
|
const queryClient = new QueryClient({
|
||||||
defaultOptions: {
|
defaultOptions: {
|
||||||
@@ -55,9 +51,7 @@ const router = createRouter({
|
|||||||
// search field) must not trigger a transition on every keystroke.
|
// search field) must not trigger a transition on every keystroke.
|
||||||
defaultViewTransition: {
|
defaultViewTransition: {
|
||||||
types: ({ pathChanged }) =>
|
types: ({ pathChanged }) =>
|
||||||
pathChanged && document.visibilityState === "visible"
|
pathChanged && document.visibilityState === "visible" ? ["page"] : false,
|
||||||
? ["page"]
|
|
||||||
: false,
|
|
||||||
},
|
},
|
||||||
scrollRestoration: true,
|
scrollRestoration: true,
|
||||||
scrollRestorationBehavior: "auto",
|
scrollRestorationBehavior: "auto",
|
||||||
@@ -101,12 +95,6 @@ function ProviderWrapper() {
|
|||||||
});
|
});
|
||||||
}, [api?.accessToken, fetchCurrentUser, createApi]);
|
}, [api?.accessToken, fetchCurrentUser, createApi]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (api) {
|
|
||||||
console.log(`API is set - Route ${window.location.pathname}`);
|
|
||||||
console.log(api);
|
|
||||||
} else {
|
|
||||||
console.log(`API is not set - Route ${window.location.pathname}`);
|
|
||||||
}
|
|
||||||
router.invalidate(); // This is a hack to force the router to re-evaluate the routes and re-run the beforeLoad functions
|
router.invalidate(); // This is a hack to force the router to re-evaluate the routes and re-run the beforeLoad functions
|
||||||
}, [api?.accessToken]);
|
}, [api?.accessToken]);
|
||||||
return (
|
return (
|
||||||
@@ -177,9 +165,7 @@ const init = async () => {
|
|||||||
<QueryClientProvider client={queryClient}>
|
<QueryClientProvider client={queryClient}>
|
||||||
<CentralProvider
|
<CentralProvider
|
||||||
initialUser={
|
initialUser={
|
||||||
initialUser
|
initialUser ? { Id: initialUser.Id, Name: initialUser.Name } : null
|
||||||
? { Id: initialUser.Id, Name: initialUser.Name }
|
|
||||||
: null
|
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<ApiProvider initialApi={initialApi}>
|
<ApiProvider initialApi={initialApi}>
|
||||||
|
|||||||
+15
-1
@@ -4,6 +4,7 @@ import { ThemeProvider } from "@mui/material/styles";
|
|||||||
import { createRootRouteWithContext, Outlet } from "@tanstack/react-router";
|
import { createRootRouteWithContext, Outlet } from "@tanstack/react-router";
|
||||||
import { SnackbarProvider } from "notistack";
|
import { SnackbarProvider } from "notistack";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import { AppStatusOverlay } from "@/components/appStatus";
|
||||||
import { AppTitlebar } from "@/components/appTitlebar";
|
import { AppTitlebar } from "@/components/appTitlebar";
|
||||||
import MobilePreview from "@/components/mobilePreview";
|
import MobilePreview from "@/components/mobilePreview";
|
||||||
// import NProgress from "@/components/nProgress";
|
// import NProgress from "@/components/nProgress";
|
||||||
@@ -25,6 +26,7 @@ import Backdrop from "@/components/backdrop";
|
|||||||
import DeepLinkHandler from "@/components/deepLinks";
|
import DeepLinkHandler from "@/components/deepLinks";
|
||||||
import FollowMe from "@/components/followMe";
|
import FollowMe from "@/components/followMe";
|
||||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||||
|
import NotificationBridge from "@/components/notifications";
|
||||||
import OverlayScrollbar from "@/components/overlayScrollbar";
|
import OverlayScrollbar from "@/components/overlayScrollbar";
|
||||||
import PlaybackSync from "@/components/playback/PlaybackSync";
|
import PlaybackSync from "@/components/playback/PlaybackSync";
|
||||||
import QuickConnectApprovalDialog from "@/components/quickConnectApproval";
|
import QuickConnectApprovalDialog from "@/components/quickConnectApproval";
|
||||||
@@ -56,7 +58,18 @@ export const Route = createRootRouteWithContext<ApiContext>()({
|
|||||||
return (
|
return (
|
||||||
<DndProvider backend={HTML5Backend}>
|
<DndProvider backend={HTML5Backend}>
|
||||||
<ThemeProvider theme={theme}>
|
<ThemeProvider theme={theme}>
|
||||||
<SnackbarProvider maxSnack={5}>
|
<SnackbarProvider
|
||||||
|
maxSnack={3}
|
||||||
|
autoHideDuration={3200}
|
||||||
|
preventDuplicate
|
||||||
|
Components={{
|
||||||
|
success: NotificationBridge,
|
||||||
|
error: NotificationBridge,
|
||||||
|
warning: NotificationBridge,
|
||||||
|
info: NotificationBridge,
|
||||||
|
default: NotificationBridge,
|
||||||
|
}}
|
||||||
|
>
|
||||||
<CssBaseline />
|
<CssBaseline />
|
||||||
<SplashHider />
|
<SplashHider />
|
||||||
{/* <NProgress /> */}
|
{/* <NProgress /> */}
|
||||||
@@ -73,6 +86,7 @@ export const Route = createRootRouteWithContext<ApiContext>()({
|
|||||||
<QuickConnectApprovalDialog />
|
<QuickConnectApprovalDialog />
|
||||||
<DeepLinkHandler />
|
<DeepLinkHandler />
|
||||||
<AppTitlebar />
|
<AppTitlebar />
|
||||||
|
<AppStatusOverlay />
|
||||||
<MobilePreview />
|
<MobilePreview />
|
||||||
<WindowChrome />
|
<WindowChrome />
|
||||||
<WindowDrag />
|
<WindowDrag />
|
||||||
|
|||||||
@@ -341,5 +341,3 @@ function FavoritePage() {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default FavoritePage;
|
|
||||||
@@ -400,5 +400,3 @@ function HomeContent({ api, user }: { api: Api; user: UserDto }) {
|
|||||||
</main>
|
</main>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Home;
|
|
||||||
@@ -1,14 +1,13 @@
|
|||||||
import AppBarBackOnly from "@/components/appBar/backOnly";
|
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||||
import { Outlet, createFileRoute, redirect } from "@tanstack/react-router";
|
import { createFileRoute, Outlet, redirect } from "@tanstack/react-router";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import AppBarBackOnly from "@/components/appBar/backOnly";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/login")({
|
export const Route = createFileRoute("/_api/login")({
|
||||||
beforeLoad: async ({ context, location }) => {
|
beforeLoad: async ({ context, location }) => {
|
||||||
if (location.pathname === "/login") {
|
if (location.pathname === "/login") {
|
||||||
const api = context.api;
|
const api = context.api;
|
||||||
if (!api) {
|
if (!api) {
|
||||||
console.info("Awaiting Api generation.");
|
|
||||||
// throw redirect({ to: "/login/manual" });
|
// throw redirect({ to: "/login/manual" });
|
||||||
} else {
|
} else {
|
||||||
const publicUsers = (await getUserApi(api).getPublicUsers()).data;
|
const publicUsers = (await getUserApi(api).getPublicUsers()).data;
|
||||||
|
|||||||
@@ -2,13 +2,14 @@ import { BaseItemKind, 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 Box from "@mui/material/Box";
|
import Box from "@mui/material/Box";
|
||||||
import CircularProgress from "@mui/material/CircularProgress";
|
import CircularProgress from "@mui/material/CircularProgress";
|
||||||
import { createFileRoute, Link } from "@tanstack/react-router";
|
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { createFileRoute, Link } from "@tanstack/react-router";
|
||||||
import React, { useLayoutEffect, useMemo } from "react";
|
import React, { useLayoutEffect, useMemo } from "react";
|
||||||
import AlbumMusicTrack from "@/components/albumMusicTrack";
|
import AlbumMusicTrack from "@/components/albumMusicTrack";
|
||||||
import InstantMixButton from "@/components/buttons/instantMixButton";
|
import InstantMixButton from "@/components/buttons/instantMixButton";
|
||||||
import LikeButton from "@/components/buttons/likeButton";
|
import LikeButton from "@/components/buttons/likeButton";
|
||||||
import PlayButton from "@/components/buttons/playButton";
|
import PlayButton from "@/components/buttons/playButton";
|
||||||
|
import RatingControl from "@/components/buttons/ratingControl";
|
||||||
import { Card } from "@/components/card/card";
|
import { Card } from "@/components/card/card";
|
||||||
import CardScroller from "@/components/cardScroller/cardScroller";
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||||
@@ -86,6 +87,7 @@ function MusicAlbumTitlePage() {
|
|||||||
sortOrder: [SortOrder.Ascending],
|
sortOrder: [SortOrder.Ascending],
|
||||||
sortBy: ["IndexNumber", "ParentIndexNumber"],
|
sortBy: ["IndexNumber", "ParentIndexNumber"],
|
||||||
fields: ["MediaSources"],
|
fields: ["MediaSources"],
|
||||||
|
enableUserData: true,
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
@@ -179,9 +181,7 @@ function MusicAlbumTitlePage() {
|
|||||||
<div className="music-hero-info">
|
<div className="music-hero-info">
|
||||||
<div className="music-eyebrow">
|
<div className="music-eyebrow">
|
||||||
{trackCount > 1 ? "Альбом" : "Сингл"}
|
{trackCount > 1 ? "Альбом" : "Сингл"}
|
||||||
{item.data.ProductionYear
|
{item.data.ProductionYear ? ` · ${item.data.ProductionYear}` : ""}
|
||||||
? ` · ${item.data.ProductionYear}`
|
|
||||||
: ""}
|
|
||||||
</div>
|
</div>
|
||||||
<h1 className="music-title">{item.data.Name}</h1>
|
<h1 className="music-title">{item.data.Name}</h1>
|
||||||
{artistId ? (
|
{artistId ? (
|
||||||
@@ -217,6 +217,14 @@ function MusicAlbumTitlePage() {
|
|||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
itemName={item.data.Name}
|
itemName={item.data.Name}
|
||||||
/>
|
/>
|
||||||
|
<RatingControl
|
||||||
|
itemId={item.data.Id}
|
||||||
|
likes={item.data.UserData?.Likes}
|
||||||
|
queryKey={["item", id]}
|
||||||
|
userId={user?.Id}
|
||||||
|
itemName={item.data.Name}
|
||||||
|
compact
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
@@ -228,8 +236,8 @@ function MusicAlbumTitlePage() {
|
|||||||
<span>Время</span>
|
<span>Время</span>
|
||||||
<span />
|
<span />
|
||||||
</div>
|
</div>
|
||||||
{allDiscs.length > 1 ? (
|
{allDiscs.length > 1
|
||||||
allDiscs.map((disc) => (
|
? allDiscs.map((disc) => (
|
||||||
<div key={disc} className="music-disc">
|
<div key={disc} className="music-disc">
|
||||||
<h2 className="music-disc-title">Диск {disc}</h2>
|
<h2 className="music-disc-title">Диск {disc}</h2>
|
||||||
{musicTracks.data?.Items?.map((track, index) =>
|
{musicTracks.data?.Items?.map((track, index) =>
|
||||||
@@ -239,24 +247,22 @@ function MusicAlbumTitlePage() {
|
|||||||
track={track}
|
track={track}
|
||||||
trackIndex={index}
|
trackIndex={index}
|
||||||
musicTracks={musicTracks.data ?? null}
|
musicTracks={musicTracks.data ?? null}
|
||||||
|
queryKey={["item", "musicTracks", id]}
|
||||||
/>
|
/>
|
||||||
) : null,
|
) : null,
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
))
|
))
|
||||||
) : (
|
: musicTracks.data?.Items?.map((track, index) => (
|
||||||
musicTracks.data?.Items?.map((track, index) => (
|
|
||||||
<AlbumMusicTrack
|
<AlbumMusicTrack
|
||||||
key={track.Id}
|
key={track.Id}
|
||||||
track={track}
|
track={track}
|
||||||
trackIndex={index}
|
trackIndex={index}
|
||||||
musicTracks={musicTracks.data ?? null}
|
musicTracks={musicTracks.data ?? null}
|
||||||
|
queryKey={["item", "musicTracks", id]}
|
||||||
/>
|
/>
|
||||||
))
|
))}
|
||||||
)}
|
{trackCount === 0 && <p className="music-empty">Треки не найдены</p>}
|
||||||
{trackCount === 0 && (
|
|
||||||
<p className="music-empty">Треки не найдены</p>
|
|
||||||
)}
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{(genres.length > 0 || item.data.Overview) && (
|
{(genres.length > 0 || item.data.Overview) && (
|
||||||
@@ -265,18 +271,12 @@ function MusicAlbumTitlePage() {
|
|||||||
{genres.length > 0 && (
|
{genres.length > 0 && (
|
||||||
<div className="music-genres">
|
<div className="music-genres">
|
||||||
{genres.map((genre) => (
|
{genres.map((genre) => (
|
||||||
<TagChip
|
<TagChip label={genre.Name ?? "жанр"} key={genre.Id} />
|
||||||
label={genre.Name ?? "жанр"}
|
|
||||||
key={genre.Id}
|
|
||||||
/>
|
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{item.data.Overview && (
|
{item.data.Overview && (
|
||||||
<ShowMoreText
|
<ShowMoreText content={item.data.Overview} collapsedLines={5} />
|
||||||
content={item.data.Overview}
|
|
||||||
collapsedLines={5}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
</section>
|
</section>
|
||||||
)}
|
)}
|
||||||
@@ -330,5 +330,3 @@ function MusicAlbumTitlePage() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default MusicAlbumTitlePage;
|
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import type { Api } from "@jellyfin/sdk";
|
||||||
|
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||||
import {
|
import {
|
||||||
BaseItemKind,
|
BaseItemKind,
|
||||||
ItemFields,
|
ItemFields,
|
||||||
@@ -11,12 +13,11 @@ import Tooltip from "@mui/material/Tooltip";
|
|||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
import React, { useEffect, useMemo, useState } from "react";
|
import React, { useEffect, useMemo, useState } from "react";
|
||||||
import type { Api } from "@jellyfin/sdk";
|
|
||||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
|
||||||
import AlbumMusicTrack from "@/components/albumMusicTrack";
|
import AlbumMusicTrack from "@/components/albumMusicTrack";
|
||||||
import InstantMixButton from "@/components/buttons/instantMixButton";
|
import InstantMixButton from "@/components/buttons/instantMixButton";
|
||||||
import LikeButton from "@/components/buttons/likeButton";
|
import LikeButton from "@/components/buttons/likeButton";
|
||||||
import PlayButton from "@/components/buttons/playButton";
|
import PlayButton from "@/components/buttons/playButton";
|
||||||
|
import RatingControl from "@/components/buttons/ratingControl";
|
||||||
import { Card } from "@/components/card/card";
|
import { Card } from "@/components/card/card";
|
||||||
import IconLink from "@/components/iconLink";
|
import IconLink from "@/components/iconLink";
|
||||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||||
@@ -109,6 +110,7 @@ function ArtistTitlePage() {
|
|||||||
includeItemTypes: [BaseItemKind.Audio],
|
includeItemTypes: [BaseItemKind.Audio],
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
fields: [ItemFields.Overview],
|
fields: [ItemFields.Overview],
|
||||||
|
enableUserData: true,
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
@@ -154,7 +156,8 @@ function ArtistTitlePage() {
|
|||||||
if (artistDiscography.data && artistSongs.data && artistAppearances.data) {
|
if (artistDiscography.data && artistSongs.data && artistAppearances.data) {
|
||||||
if (artistDiscography.data.TotalRecordCount) setActiveTab("discography");
|
if (artistDiscography.data.TotalRecordCount) setActiveTab("discography");
|
||||||
else if (artistSongs.data.TotalRecordCount) setActiveTab("songs");
|
else if (artistSongs.data.TotalRecordCount) setActiveTab("songs");
|
||||||
else if (artistAppearances.data.TotalRecordCount) setActiveTab("appearances");
|
else if (artistAppearances.data.TotalRecordCount)
|
||||||
|
setActiveTab("appearances");
|
||||||
}
|
}
|
||||||
}, [artistDiscography.data, artistSongs.data, artistAppearances.data]);
|
}, [artistDiscography.data, artistSongs.data, artistAppearances.data]);
|
||||||
|
|
||||||
@@ -267,13 +270,18 @@ function ArtistTitlePage() {
|
|||||||
isFavorite={item.data.UserData?.IsFavorite}
|
isFavorite={item.data.UserData?.IsFavorite}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
|
<RatingControl
|
||||||
|
itemId={item.data.Id}
|
||||||
|
likes={item.data.UserData?.Likes}
|
||||||
|
queryKey={["item", id]}
|
||||||
|
userId={user?.Id}
|
||||||
|
itemName={item.data.Name}
|
||||||
|
compact
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
{item.data.Overview && (
|
{item.data.Overview && (
|
||||||
<div className="music-artist-about">
|
<div className="music-artist-about">
|
||||||
<ShowMoreText
|
<ShowMoreText content={item.data.Overview} collapsedLines={3} />
|
||||||
content={item.data.Overview}
|
|
||||||
collapsedLines={3}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{(item.data.ExternalUrls?.length ?? 0) > 0 && (
|
{(item.data.ExternalUrls?.length ?? 0) > 0 && (
|
||||||
@@ -336,6 +344,7 @@ function ArtistTitlePage() {
|
|||||||
track={track}
|
track={track}
|
||||||
trackIndex={index}
|
trackIndex={index}
|
||||||
musicTracks={artistSongs.data ?? null}
|
musicTracks={artistSongs.data ?? null}
|
||||||
|
queryKey={["item", id, "artist", "songs"]}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
{songCount === 0 && <p className="music-empty">Песен пока нет</p>}
|
{songCount === 0 && <p className="music-empty">Песен пока нет</p>}
|
||||||
@@ -362,5 +371,3 @@ function ArtistTitlePage() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ArtistTitlePage;
|
|
||||||
@@ -119,6 +119,7 @@
|
|||||||
|
|
||||||
.music-actions {
|
.music-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 0.5em;
|
gap: 0.5em;
|
||||||
margin-top: 1.6em;
|
margin-top: 1.6em;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import React, { useEffect } from "react";
|
|||||||
import AlbumMusicTrack from "@/components/albumMusicTrack";
|
import AlbumMusicTrack from "@/components/albumMusicTrack";
|
||||||
import LikeButton from "@/components/buttons/likeButton";
|
import LikeButton from "@/components/buttons/likeButton";
|
||||||
import PlayButton from "@/components/buttons/playButton";
|
import PlayButton from "@/components/buttons/playButton";
|
||||||
|
import RatingControl from "@/components/buttons/ratingControl";
|
||||||
import { Card } from "@/components/card/card";
|
import { Card } from "@/components/card/card";
|
||||||
import CardScroller from "@/components/cardScroller/cardScroller";
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||||
@@ -82,6 +83,7 @@ function PlaylistTitlePage() {
|
|||||||
const result = await getPlaylistApi(api).getPlaylistItems({
|
const result = await getPlaylistApi(api).getPlaylistItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
playlistId: item.data.Id,
|
playlistId: item.data.Id,
|
||||||
|
enableUserData: true,
|
||||||
});
|
});
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
@@ -169,6 +171,14 @@ function PlaylistTitlePage() {
|
|||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
itemName={item.data.Name}
|
itemName={item.data.Name}
|
||||||
/>
|
/>
|
||||||
|
<RatingControl
|
||||||
|
itemId={item.data.Id}
|
||||||
|
likes={item.data.UserData?.Likes}
|
||||||
|
queryKey={["item", id]}
|
||||||
|
userId={user?.Id}
|
||||||
|
itemName={item.data.Name}
|
||||||
|
compact
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
@@ -186,6 +196,7 @@ function PlaylistTitlePage() {
|
|||||||
track={track}
|
track={track}
|
||||||
trackIndex={index}
|
trackIndex={index}
|
||||||
musicTracks={musicTracks.data ?? null}
|
musicTracks={musicTracks.data ?? null}
|
||||||
|
queryKey={["item", id, "musicTracks"]}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
{trackCount === 0 && (
|
{trackCount === 0 && (
|
||||||
@@ -204,10 +215,7 @@ function PlaylistTitlePage() {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{item.data.Overview && (
|
{item.data.Overview && (
|
||||||
<ShowMoreText
|
<ShowMoreText content={item.data.Overview} collapsedLines={5} />
|
||||||
content={item.data.Overview}
|
|
||||||
collapsedLines={5}
|
|
||||||
/>
|
|
||||||
)}
|
)}
|
||||||
</section>
|
</section>
|
||||||
)}
|
)}
|
||||||
@@ -256,5 +264,3 @@ function PlaylistTitlePage() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default PlaylistTitlePage;
|
|
||||||
@@ -11,7 +11,12 @@ import {
|
|||||||
Tooltip,
|
Tooltip,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { createFileRoute, Link, useNavigate, useRouter } from "@tanstack/react-router";
|
import {
|
||||||
|
createFileRoute,
|
||||||
|
Link,
|
||||||
|
useNavigate,
|
||||||
|
useRouter,
|
||||||
|
} from "@tanstack/react-router";
|
||||||
import { AnimatePresence, motion } from "motion/react";
|
import { AnimatePresence, motion } from "motion/react";
|
||||||
import React, {
|
import React, {
|
||||||
useEffect,
|
useEffect,
|
||||||
@@ -22,9 +27,8 @@ import React, {
|
|||||||
} from "react";
|
} from "react";
|
||||||
import CastButton from "@/components/buttons/castButton";
|
import CastButton from "@/components/buttons/castButton";
|
||||||
import LikeButton from "@/components/buttons/likeButton";
|
import LikeButton from "@/components/buttons/likeButton";
|
||||||
import LyricsPanel, {
|
import RatingControl from "@/components/buttons/ratingControl";
|
||||||
getLyricsQueryOptions,
|
import LyricsPanel from "@/components/playback/audioPlayer/components/LyricsPanel";
|
||||||
} from "@/components/playback/audioPlayer/components/LyricsPanel";
|
|
||||||
import PlayerVolume from "@/components/playback/audioPlayer/components/PlayerVolume";
|
import PlayerVolume from "@/components/playback/audioPlayer/components/PlayerVolume";
|
||||||
import StatsPanel from "@/components/playback/audioPlayer/components/StatsPanel";
|
import StatsPanel from "@/components/playback/audioPlayer/components/StatsPanel";
|
||||||
import WindowControls from "@/components/windowControls";
|
import WindowControls from "@/components/windowControls";
|
||||||
@@ -268,8 +272,6 @@ function AudioPlayerRoute() {
|
|||||||
...getItemQueryOptions(item?.Id ?? "", api, user?.Id),
|
...getItemQueryOptions(item?.Id ?? "", api, user?.Id),
|
||||||
enabled: Boolean(item?.Id && api && user?.Id),
|
enabled: Boolean(item?.Id && api && user?.Id),
|
||||||
});
|
});
|
||||||
const lyrics = useQuery(getLyricsQueryOptions(item, api));
|
|
||||||
const hasLyrics = (lyrics.data?.Lyrics?.length ?? 0) > 0;
|
|
||||||
|
|
||||||
// Wall colour derived from the sleeve.
|
// Wall colour derived from the sleeve.
|
||||||
const palette = useMemo(() => getCoverPalette(item), [item]);
|
const palette = useMemo(() => getCoverPalette(item), [item]);
|
||||||
@@ -333,9 +335,7 @@ function AudioPlayerRoute() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div
|
<div className={`music-player${panelOpen ? " has-panel" : ""}`}>
|
||||||
className={`music-player${panelOpen ? " has-panel" : ""}`}
|
|
||||||
>
|
|
||||||
<AnimatePresence initial={false} mode="sync">
|
<AnimatePresence initial={false} mode="sync">
|
||||||
<motion.div
|
<motion.div
|
||||||
key={item?.Id ?? "no-item"}
|
key={item?.Id ?? "no-item"}
|
||||||
@@ -372,10 +372,7 @@ function AudioPlayerRoute() {
|
|||||||
<div className="music-player-stage">
|
<div className="music-player-stage">
|
||||||
<div className="music-player-row">
|
<div className="music-player-row">
|
||||||
<div className="music-player-main">
|
<div className="music-player-main">
|
||||||
<CoverArt
|
<CoverArt src={imageUrl} alt={item?.Name ?? "Обложка"} />
|
||||||
src={imageUrl}
|
|
||||||
alt={item?.Name ?? "Обложка"}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className="music-player-meta">
|
<div className="music-player-meta">
|
||||||
<h1 className="music-player-title">{item?.Name}</h1>
|
<h1 className="music-player-title">{item?.Name}</h1>
|
||||||
@@ -460,34 +457,34 @@ function AudioPlayerRoute() {
|
|||||||
aria-label="Закрыть"
|
aria-label="Закрыть"
|
||||||
onClick={() => setPanelOpen(false)}
|
onClick={() => setPanelOpen(false)}
|
||||||
>
|
>
|
||||||
<span className="material-symbols-rounded">close</span>
|
<span className="material-symbols-rounded">
|
||||||
|
close
|
||||||
|
</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</div>
|
</div>
|
||||||
<div className="music-player-panel-body music-player-panel-lyrics">
|
<div className="music-player-panel-body music-player-panel-lyrics">
|
||||||
{hasLyrics ? (
|
|
||||||
<LyricsPanel
|
<LyricsPanel
|
||||||
item={item}
|
item={item}
|
||||||
api={api}
|
api={api}
|
||||||
currentTime={progress}
|
currentTime={progress}
|
||||||
onSeek={handleSeekCommit}
|
onSeek={handleSeekCommit}
|
||||||
/>
|
/>
|
||||||
) : (
|
|
||||||
<p className="music-player-panel-empty">
|
|
||||||
Для этого трека нет текста.
|
|
||||||
</p>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<div className="music-player-panel-head">
|
<div className="music-player-panel-head">
|
||||||
<span className="music-player-panel-source">Очередь</span>
|
<span className="music-player-panel-source">
|
||||||
|
Очередь
|
||||||
|
</span>
|
||||||
<IconButton
|
<IconButton
|
||||||
size="small"
|
size="small"
|
||||||
aria-label="Закрыть"
|
aria-label="Закрыть"
|
||||||
onClick={() => setPanelOpen(false)}
|
onClick={() => setPanelOpen(false)}
|
||||||
>
|
>
|
||||||
<span className="material-symbols-rounded">close</span>
|
<span className="material-symbols-rounded">
|
||||||
|
close
|
||||||
|
</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</div>
|
</div>
|
||||||
<div className="music-player-panel-body">
|
<div className="music-player-panel-body">
|
||||||
@@ -533,6 +530,14 @@ function AudioPlayerRoute() {
|
|||||||
queryKey={["item", item?.Id ?? ""]}
|
queryKey={["item", item?.Id ?? ""]}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
/>
|
/>
|
||||||
|
<RatingControl
|
||||||
|
itemId={item?.Id}
|
||||||
|
likes={itemDetails.data?.UserData?.Likes ?? item?.UserData?.Likes}
|
||||||
|
queryKey={["item", item?.Id ?? ""]}
|
||||||
|
userId={user?.Id}
|
||||||
|
itemName={item?.Name}
|
||||||
|
compact
|
||||||
|
/>
|
||||||
{item && (
|
{item && (
|
||||||
<CastButton
|
<CastButton
|
||||||
item={item}
|
item={item}
|
||||||
@@ -672,7 +677,6 @@ function AudioPlayerRoute() {
|
|||||||
className={
|
className={
|
||||||
panelOpen && panelTab === "lyrics" ? "is-active" : undefined
|
panelOpen && panelTab === "lyrics" ? "is-active" : undefined
|
||||||
}
|
}
|
||||||
disabled={!hasLyrics}
|
|
||||||
>
|
>
|
||||||
<span className="material-symbols-rounded">lyrics</span>
|
<span className="material-symbols-rounded">lyrics</span>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
|||||||
@@ -88,8 +88,10 @@ function addSubtitleTrackToReactPlayer(
|
|||||||
const a = track.track;
|
const a = track.track;
|
||||||
a.mode = "showing";
|
a.mode = "showing";
|
||||||
});
|
});
|
||||||
track.addEventListener("error", (e) => {
|
track.addEventListener("error", () => {
|
||||||
console.error("Error loading subtitle track", e);
|
// Some servers advertise subtitle streams that cannot be delivered
|
||||||
|
// as a text track; the video still plays and JASSUB handles image
|
||||||
|
// subtitles separately.
|
||||||
});
|
});
|
||||||
|
|
||||||
videoElem.appendChild(track);
|
videoElem.appendChild(track);
|
||||||
@@ -99,7 +101,7 @@ function addSubtitleTrackToReactPlayer(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function VideoPlayer() {
|
function VideoPlayer() {
|
||||||
const api = useApiInContext((s) => s.api);
|
const api = useApiInContext((s) => s.api);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { history } = useRouter();
|
const { history } = useRouter();
|
||||||
@@ -357,8 +359,6 @@ export function VideoPlayer() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(mediaSource.subtitle);
|
|
||||||
|
|
||||||
registerPlayerActions({
|
registerPlayerActions({
|
||||||
seekTo: (seconds: number) => {
|
seekTo: (seconds: number) => {
|
||||||
// A user seek wins over the pending transfer/resume target.
|
// A user seek wins over the pending transfer/resume target.
|
||||||
@@ -639,9 +639,7 @@ export function VideoPlayer() {
|
|||||||
wasmUrl,
|
wasmUrl,
|
||||||
modernWasmUrl,
|
modernWasmUrl,
|
||||||
});
|
});
|
||||||
jassubRenderer.ready.then(() => {
|
jassubRenderer.ready.then(() => undefined);
|
||||||
console.log("JASSUB subtitle renderer is ready");
|
|
||||||
});
|
|
||||||
} else if (
|
} else if (
|
||||||
mediaSource.subtitle.format === "subrip" ||
|
mediaSource.subtitle.format === "subrip" ||
|
||||||
mediaSource.subtitle.format === "vtt"
|
mediaSource.subtitle.format === "vtt"
|
||||||
|
|||||||
@@ -505,5 +505,3 @@ function CategorySkeleton() {
|
|||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SearchPage;
|
|
||||||
@@ -54,7 +54,6 @@ function ServerSetup() {
|
|||||||
enqueueSnackbar("Что-то пошло не так", { variant: "error" });
|
enqueueSnackbar("Что-то пошло не так", { variant: "error" });
|
||||||
},
|
},
|
||||||
onSettled: (bestServer) => {
|
onSettled: (bestServer) => {
|
||||||
console.log(bestServer);
|
|
||||||
if (!bestServer) {
|
if (!bestServer) {
|
||||||
enqueueSnackbar("Указанный адрес не является сервером Jellyfin.", {
|
enqueueSnackbar("Указанный адрес не является сервером Jellyfin.", {
|
||||||
variant: "error",
|
variant: "error",
|
||||||
|
|||||||
@@ -234,4 +234,3 @@ function ServerList() {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
export default ServerList;
|
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
import type { BaseItemDto, ImageType } from "@jellyfin/sdk/lib/generated-client";
|
import type {
|
||||||
|
BaseItemDto,
|
||||||
|
ImageType,
|
||||||
|
} from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
|
||||||
export type ResolvedItemImage = {
|
export type ResolvedItemImage = {
|
||||||
/** Item that actually owns the image (episodes borrow their series' artwork). */
|
/** Item that actually owns the image (episodes borrow their series' artwork). */
|
||||||
@@ -47,12 +50,15 @@ export const resolveItemImage = (
|
|||||||
// Library grids show one poster per episode, owned by the series.
|
// Library grids show one poster per episode, owned by the series.
|
||||||
const seriesId = options.seriesId ?? item.SeriesId;
|
const seriesId = options.seriesId ?? item.SeriesId;
|
||||||
if (options.seriesId && seriesId) {
|
if (options.seriesId && seriesId) {
|
||||||
|
const seriesPrimaryTag = item.SeriesPrimaryImageTag ?? undefined;
|
||||||
|
if (seriesPrimaryTag) {
|
||||||
return {
|
return {
|
||||||
itemId: seriesId,
|
itemId: seriesId,
|
||||||
imageType: "Primary",
|
imageType: "Primary",
|
||||||
tag: item.SeriesPrimaryImageTag ?? undefined,
|
tag: seriesPrimaryTag,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const order = ownFallbackOrder[preferred] ?? [preferred];
|
const order = ownFallbackOrder[preferred] ?? [preferred];
|
||||||
for (const type of order) {
|
for (const type of order) {
|
||||||
@@ -69,9 +75,6 @@ export const resolveItemImage = (
|
|||||||
tag: item.SeriesPrimaryImageTag,
|
tag: item.SeriesPrimaryImageTag,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (seriesId && item.Type === "Episode") {
|
|
||||||
return { itemId: seriesId, imageType: "Primary" };
|
|
||||||
}
|
|
||||||
// Audio inherits its cover from the album.
|
// Audio inherits its cover from the album.
|
||||||
if (item.AlbumId) {
|
if (item.AlbumId) {
|
||||||
return { itemId: item.AlbumId, imageType: "Primary" };
|
return { itemId: item.AlbumId, imageType: "Primary" };
|
||||||
@@ -84,11 +87,9 @@ export const resolveItemImage = (
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nothing known: keep the requested type so the server gets a chance, but
|
// Do not invent an image URL when the item has no advertised artwork:
|
||||||
// only when the item exists. Callers render their icon placeholder on 404.
|
// requesting /Images/Primary for such items only produces 404 noise. The
|
||||||
if (item.Id) {
|
// card/hero fall back to their own placeholder icon instead.
|
||||||
return { itemId: item.Id, imageType: preferred };
|
|
||||||
}
|
|
||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -64,13 +64,28 @@ export const playOnSession = async (
|
|||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
if (options.itemIds.length === 0) return;
|
if (options.itemIds.length === 0) return;
|
||||||
|
|
||||||
const sessionApi = getSessionApi(api);
|
// The Jellyfin Play endpoint takes every queue item as a repeated query
|
||||||
const startPositionTicks = Math.max(0, options.startPositionTicks ?? 0);
|
// parameter. A whole library/playlist can exceed the proxy URL limit and
|
||||||
const startIndex = Math.min(
|
// the connection is closed before the request reaches the server. Send a
|
||||||
|
// window of the queue around the current item; 40 is plenty for hand-off.
|
||||||
|
const MAX_REMOTE_QUEUE = 40;
|
||||||
|
const requestedIndex = Math.min(
|
||||||
Math.max(0, options.startIndex ?? 0),
|
Math.max(0, options.startIndex ?? 0),
|
||||||
options.itemIds.length - 1,
|
options.itemIds.length - 1,
|
||||||
);
|
);
|
||||||
const expectedItemId = options.itemIds[startIndex];
|
const windowStart = Math.max(
|
||||||
|
0,
|
||||||
|
Math.min(requestedIndex, options.itemIds.length - MAX_REMOTE_QUEUE),
|
||||||
|
);
|
||||||
|
const itemIds = options.itemIds.slice(
|
||||||
|
windowStart,
|
||||||
|
windowStart + MAX_REMOTE_QUEUE,
|
||||||
|
);
|
||||||
|
const startIndex = requestedIndex - windowStart;
|
||||||
|
const expectedItemId = itemIds[startIndex];
|
||||||
|
|
||||||
|
const sessionApi = getSessionApi(api);
|
||||||
|
const startPositionTicks = Math.max(0, options.startPositionTicks ?? 0);
|
||||||
|
|
||||||
const readTarget = async () => {
|
const readTarget = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -106,7 +121,7 @@ export const playOnSession = async (
|
|||||||
await sessionApi.play({
|
await sessionApi.play({
|
||||||
sessionId,
|
sessionId,
|
||||||
playCommand: "PlayNow",
|
playCommand: "PlayNow",
|
||||||
itemIds: options.itemIds,
|
itemIds,
|
||||||
startIndex,
|
startIndex,
|
||||||
startPositionTicks,
|
startPositionTicks,
|
||||||
mediaSourceId: options.mediaSourceId,
|
mediaSourceId: options.mediaSourceId,
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ export const getLibraryItemsQueryOptions = (
|
|||||||
);
|
);
|
||||||
return { Items: [], TotalRecordCount: 0 } as BaseItemDtoQueryResult;
|
return { Items: [], TotalRecordCount: 0 } as BaseItemDtoQueryResult;
|
||||||
}
|
}
|
||||||
console.info("Fetching library items with params:", params);
|
|
||||||
const { currentViewType, videoTypesState, filters } = params;
|
const { currentViewType, videoTypesState, filters } = params;
|
||||||
const buildVideoTypes = (state: typeof videoTypesState) => {
|
const buildVideoTypes = (state: typeof videoTypesState) => {
|
||||||
const videoTypes: VideoType[] = [];
|
const videoTypes: VideoType[] = [];
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ export const setSetting = async (settingKey: string, value: boolean) => {
|
|||||||
|
|
||||||
export const getSetting = async (settingKey: string) => {
|
export const getSetting = async (settingKey: string) => {
|
||||||
const value = await SettingsStore.get(settingKey);
|
const value = await SettingsStore.get(settingKey);
|
||||||
console.log(`${settingKey} - ${value}`);
|
|
||||||
if (value) return value;
|
if (value) return value;
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
import { create } from "zustand";
|
||||||
|
|
||||||
|
export type AppStatusPhase =
|
||||||
|
| "idle"
|
||||||
|
| "loading"
|
||||||
|
| "success"
|
||||||
|
| "warning"
|
||||||
|
| "error"
|
||||||
|
| "info";
|
||||||
|
|
||||||
|
type AppStatusState = {
|
||||||
|
phase: AppStatusPhase;
|
||||||
|
message: string;
|
||||||
|
/** Bumped on every notification so stale timers can be ignored. */
|
||||||
|
token: number;
|
||||||
|
notify: (variant: string, message: unknown) => void;
|
||||||
|
reset: () => void;
|
||||||
|
};
|
||||||
|
|
||||||
|
let resultTimer: ReturnType<typeof setTimeout> | null = null;
|
||||||
|
let idleTimer: ReturnType<typeof setTimeout> | null = null;
|
||||||
|
|
||||||
|
const clearTimers = () => {
|
||||||
|
if (resultTimer) clearTimeout(resultTimer);
|
||||||
|
if (idleTimer) clearTimeout(idleTimer);
|
||||||
|
resultTimer = null;
|
||||||
|
idleTimer = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
const messageText = (message: unknown): string => {
|
||||||
|
if (typeof message === "string") return message;
|
||||||
|
if (typeof message === "number") return String(message);
|
||||||
|
if (message && typeof message === "object") {
|
||||||
|
const props = (message as { props?: { children?: unknown } }).props;
|
||||||
|
if (typeof props?.children === "string") return props.children;
|
||||||
|
}
|
||||||
|
return "Готово";
|
||||||
|
};
|
||||||
|
|
||||||
|
const phaseForVariant = (variant: string): AppStatusPhase => {
|
||||||
|
switch (variant) {
|
||||||
|
case "success":
|
||||||
|
return "success";
|
||||||
|
case "error":
|
||||||
|
return "error";
|
||||||
|
case "warning":
|
||||||
|
return "warning";
|
||||||
|
default:
|
||||||
|
return "info";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useAppStatusStore = create<AppStatusState>((set) => ({
|
||||||
|
phase: "idle",
|
||||||
|
message: "",
|
||||||
|
token: 0,
|
||||||
|
notify: (variant, message) => {
|
||||||
|
clearTimers();
|
||||||
|
const phase = phaseForVariant(variant);
|
||||||
|
const text = messageText(message);
|
||||||
|
const token = Date.now();
|
||||||
|
set({ phase: "loading", message: text, token });
|
||||||
|
|
||||||
|
// A short spinner beat makes the titlebar icon feel like a process
|
||||||
|
// completing (spinner → check / warning) rather than a random blink.
|
||||||
|
resultTimer = setTimeout(() => {
|
||||||
|
resultTimer = null;
|
||||||
|
set({ phase, message: text, token });
|
||||||
|
idleTimer = setTimeout(() => {
|
||||||
|
idleTimer = null;
|
||||||
|
set({ phase: "idle", message: "", token: 0 });
|
||||||
|
}, 2600);
|
||||||
|
}, 450);
|
||||||
|
},
|
||||||
|
reset: () => {
|
||||||
|
clearTimers();
|
||||||
|
set({ phase: "idle", message: "", token: 0 });
|
||||||
|
},
|
||||||
|
}));
|
||||||
@@ -565,7 +565,6 @@ export const usePlaybackStore = create<
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
registerPlayerActions: (actions) => {
|
registerPlayerActions: (actions) => {
|
||||||
console.info("Registering player actions:", actions);
|
|
||||||
set({
|
set({
|
||||||
_playerActions: actions,
|
_playerActions: actions,
|
||||||
});
|
});
|
||||||
@@ -628,10 +627,8 @@ export const usePlaybackStore = create<
|
|||||||
(s) => s.Id === activeSegmentId,
|
(s) => s.Id === activeSegmentId,
|
||||||
);
|
);
|
||||||
if (!activeSegment) {
|
if (!activeSegment) {
|
||||||
console.warn("No segment to skip");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.info("Skipping segment:", activeSegment);
|
|
||||||
get()._playerActions.seekTo(ticksToSec(activeSegment.EndTicks ?? 0));
|
get()._playerActions.seekTo(ticksToSec(activeSegment.EndTicks ?? 0));
|
||||||
},
|
},
|
||||||
handleStartSeek: (ticks) => {
|
handleStartSeek: (ticks) => {
|
||||||
@@ -653,7 +650,6 @@ export const usePlaybackStore = create<
|
|||||||
const ticks = secToTicks(seconds);
|
const ticks = secToTicks(seconds);
|
||||||
const segments = get().metadata.mediaSegments?.Items;
|
const segments = get().metadata.mediaSegments?.Items;
|
||||||
if (!segments || segments.length === 0) {
|
if (!segments || segments.length === 0) {
|
||||||
console.warn("No segments available for seeking");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const segment = segments.find(
|
const segment = segments.find(
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ export const setQueue = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const setTrackIndex = (index: number) => {
|
export const setTrackIndex = (index: number) => {
|
||||||
console.info(`Setting index ${index}`);
|
|
||||||
useQueue.setState((state) => ({ ...state, currentItemIndex: index }));
|
useQueue.setState((state) => ({ ...state, currentItemIndex: index }));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user