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
55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
|
import IconButton from "@mui/material/IconButton";
|
|
import Tooltip from "@mui/material/Tooltip";
|
|
import React from "react";
|
|
import useRemoteControlStore, {
|
|
type RemoteTransfer,
|
|
} from "@/utils/store/remoteControl";
|
|
|
|
type CastButtonProps = {
|
|
item?: BaseItemDto | null;
|
|
transfer?: RemoteTransfer;
|
|
/** Computed on click so playback position/queue are current. */
|
|
getTransfer?: () => RemoteTransfer | null;
|
|
size?: "small" | "medium" | "large";
|
|
};
|
|
|
|
const CastButton = ({
|
|
item,
|
|
transfer,
|
|
getTransfer,
|
|
size = "medium",
|
|
}: CastButtonProps) => {
|
|
const openDialog = useRemoteControlStore((s) => s.openDialog);
|
|
return (
|
|
<Tooltip
|
|
title={
|
|
item
|
|
? "Передать текущее медиа на устройство"
|
|
: "Удалённое управление"
|
|
}
|
|
>
|
|
<IconButton
|
|
size={size}
|
|
aria-label={
|
|
item
|
|
? "Передать текущее медиа на устройство"
|
|
: "Удалённое управление"
|
|
}
|
|
onClick={() => {
|
|
const computed = getTransfer ? getTransfer() : transfer;
|
|
const resolvedItem = item ?? computed?.item ?? null;
|
|
openDialog({
|
|
...(computed ?? {}),
|
|
item: resolvedItem,
|
|
});
|
|
}}
|
|
>
|
|
<span className="material-symbols-rounded">cast</span>
|
|
</IconButton>
|
|
</Tooltip>
|
|
);
|
|
};
|
|
|
|
export default CastButton;
|