feat: add new preferences page
This commit is contained in:
22 files changed
+790
-131
No files matched your search
@@ -13,8 +13,8 @@
|
||||
|
||||
## 📝 Prerequisites
|
||||
|
||||
- Nodejs (≥19.1.0)
|
||||
- Rust (≥1.76.0)
|
||||
- Nodejs (22.14.0)
|
||||
- Rust (>=1.85.0)
|
||||
- Visual Studio C++ Build tools
|
||||
- [pnpm](https://pnpm.io/)
|
||||
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<script src="http://localhost:8097"></script>
|
||||
<!-- <script src="http://localhost:8097"></script> -->
|
||||
<title>Blink</title>
|
||||
<style>
|
||||
.app-loading {
|
||||
|
||||
@@ -30,9 +30,11 @@
|
||||
"@popperjs/core": "^2.11.8",
|
||||
"@react-spring/web": "^9.7.5",
|
||||
"@tanem/react-nprogress": "^5.0.55",
|
||||
"@tanstack/react-form": "^1.7.0",
|
||||
"@tanstack/react-query": "^5.74.4",
|
||||
"@tanstack/react-query-devtools": "^5.74.6",
|
||||
"@tanstack/react-router": "^1.117.1",
|
||||
"@tanstack/react-router-devtools": "^1.117.1",
|
||||
"@tanstack/react-virtual": "^3.13.6",
|
||||
"@tauri-apps/api": "2.5.0",
|
||||
"@tauri-apps/plugin-clipboard-manager": "2.2.2",
|
||||
|
||||
Generated
+45
@@ -59,6 +59,9 @@ importers:
|
||||
'@tanem/react-nprogress':
|
||||
specifier: ^5.0.55
|
||||
version: 5.0.55(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||
'@tanstack/react-form':
|
||||
specifier: ^1.7.0
|
||||
version: 1.7.0(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||
'@tanstack/react-query':
|
||||
specifier: ^5.74.4
|
||||
version: 5.74.4(react@19.1.0)
|
||||
@@ -68,6 +71,9 @@ importers:
|
||||
'@tanstack/react-router':
|
||||
specifier: ^1.117.1
|
||||
version: 1.117.1(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||
'@tanstack/react-router-devtools':
|
||||
specifier: ^1.117.1
|
||||
version: 1.117.1(@tanstack/react-router@1.117.1(react-dom@19.1.0(react@19.1.0))(react@19.1.0))(@tanstack/router-core@1.117.1)(csstype@3.1.3)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)(tiny-invariant@1.3.3)
|
||||
'@tanstack/react-virtual':
|
||||
specifier: ^3.13.6
|
||||
version: 3.13.6(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||
@@ -1368,6 +1374,9 @@ packages:
|
||||
react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
|
||||
react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
|
||||
|
||||
'@tanstack/form-core@1.7.0':
|
||||
resolution: {integrity: sha512-r2mIcccTRzuhu0+xEaR0c33OPfa64jE4xHX7LtiXAxpvwc4HzdNLCDoG9H6p8P4UcIZu8r4yH2sXDnouysSeQA==}
|
||||
|
||||
'@tanstack/history@1.115.0':
|
||||
resolution: {integrity: sha512-K7JJNrRVvyjAVnbXOH2XLRhFXDkeP54Kt2P4FR1Kl2KDGlIbkua5VqZQD2rot3qaDrpufyUa63nuLai1kOLTsQ==}
|
||||
engines: {node: '>=12'}
|
||||
@@ -1378,6 +1387,18 @@ packages:
|
||||
'@tanstack/query-devtools@5.74.6':
|
||||
resolution: {integrity: sha512-djaFT11mVCOW3e0Ezfyiq7T6OoHy2LRI1fUFQvj+G6+/4A1FkuRMNUhQkdP1GXlx8id0f1/zd5fgDpIy5SU/Iw==}
|
||||
|
||||
'@tanstack/react-form@1.7.0':
|
||||
resolution: {integrity: sha512-ANrPoUM4dFcjshLyS4Adn0UTb1V+OCijC6Ghe3v6z/jCFKMO9GXZ2WePVNWmgdXX7PknNVseoEHkDGgTJXtgLg==}
|
||||
peerDependencies:
|
||||
'@tanstack/react-start': ^1.112.0
|
||||
react: ^17.0.0 || ^18.0.0 || ^19.0.0
|
||||
vinxi: ^0.5.0
|
||||
peerDependenciesMeta:
|
||||
'@tanstack/react-start':
|
||||
optional: true
|
||||
vinxi:
|
||||
optional: true
|
||||
|
||||
'@tanstack/react-query-devtools@5.74.6':
|
||||
resolution: {integrity: sha512-vlsDwz4/FsblK0h7VAlXUdJ+9OV+i1n8OLb8CLLAZqu0M9GCnbajytZwsRmns33PXBZ6wQBJ859kg6aajx+e9Q==}
|
||||
peerDependencies:
|
||||
@@ -1916,6 +1937,9 @@ packages:
|
||||
supports-color:
|
||||
optional: true
|
||||
|
||||
decode-formdata@0.9.0:
|
||||
resolution: {integrity: sha512-q5uwOjR3Um5YD+ZWPOF/1sGHVW9A5rCrRwITQChRXlmPkxDFBqCm4jNTIVdGHNH9OnR+V9MoZVgRhsFb+ARbUw==}
|
||||
|
||||
decode-named-character-reference@1.1.0:
|
||||
resolution: {integrity: sha512-Wy+JTSbFThEOXQIR2L6mxJvEs+veIzpmqD7ynWxMXGpnk3smkHQOp6forLdHsKpAMW9iJpaBBIxz285t1n1C3w==}
|
||||
|
||||
@@ -1940,6 +1964,9 @@ packages:
|
||||
engines: {node: '>=0.10'}
|
||||
hasBin: true
|
||||
|
||||
devalue@5.1.1:
|
||||
resolution: {integrity: sha512-maua5KUiapvEwiEAe+XnlZ3Rh0GD+qI1J/nb9vrJc3muPXvcF/8gXYTWF76+5DAqHyDUtOIImEuo0YKE9mshVw==}
|
||||
|
||||
devlop@1.1.0:
|
||||
resolution: {integrity: sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==}
|
||||
|
||||
@@ -4321,12 +4348,26 @@ snapshots:
|
||||
react: 19.1.0
|
||||
react-dom: 19.1.0(react@19.1.0)
|
||||
|
||||
'@tanstack/form-core@1.7.0':
|
||||
dependencies:
|
||||
'@tanstack/store': 0.7.0
|
||||
|
||||
'@tanstack/history@1.115.0': {}
|
||||
|
||||
'@tanstack/query-core@5.74.4': {}
|
||||
|
||||
'@tanstack/query-devtools@5.74.6': {}
|
||||
|
||||
'@tanstack/react-form@1.7.0(react-dom@19.1.0(react@19.1.0))(react@19.1.0)':
|
||||
dependencies:
|
||||
'@tanstack/form-core': 1.7.0
|
||||
'@tanstack/react-store': 0.7.0(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
|
||||
decode-formdata: 0.9.0
|
||||
devalue: 5.1.1
|
||||
react: 19.1.0
|
||||
transitivePeerDependencies:
|
||||
- react-dom
|
||||
|
||||
'@tanstack/react-query-devtools@5.74.6(@tanstack/react-query@5.74.4(react@19.1.0))(react@19.1.0)':
|
||||
dependencies:
|
||||
'@tanstack/query-devtools': 5.74.6
|
||||
@@ -4881,6 +4922,8 @@ snapshots:
|
||||
dependencies:
|
||||
ms: 2.1.3
|
||||
|
||||
decode-formdata@0.9.0: {}
|
||||
|
||||
decode-named-character-reference@1.1.0:
|
||||
dependencies:
|
||||
character-entities: 2.0.2
|
||||
@@ -4896,6 +4939,8 @@ snapshots:
|
||||
detect-libc@1.0.3:
|
||||
optional: true
|
||||
|
||||
devalue@5.1.1: {}
|
||||
|
||||
devlop@1.1.0:
|
||||
dependencies:
|
||||
dequal: 2.0.3
|
||||
|
||||
@@ -45,40 +45,8 @@ import {
|
||||
ListItemText,
|
||||
} from "@mui/material";
|
||||
import BackButton from "../buttons/backButton";
|
||||
import ListItemLink from "../listItemLink";
|
||||
|
||||
interface ListItemLinkProps {
|
||||
icon?: ReactNode;
|
||||
primary: string;
|
||||
to: string;
|
||||
}
|
||||
|
||||
function ListItemLink(props: ListItemLinkProps) {
|
||||
const { icon, primary, to } = props;
|
||||
|
||||
return (
|
||||
<li>
|
||||
{/* @ts-ignore */}
|
||||
<ListItem
|
||||
component={Link}
|
||||
activeClassName="active"
|
||||
className="library-drawer-item"
|
||||
to={to}
|
||||
>
|
||||
<ListItemButton
|
||||
style={{
|
||||
borderRadius: "100px",
|
||||
gap: "0.85em",
|
||||
color: "white",
|
||||
textDecoration: "none",
|
||||
}}
|
||||
>
|
||||
<div className="material-symbols-rounded">{icon}</div>
|
||||
<ListItemText primary={primary} />
|
||||
</ListItemButton>
|
||||
</ListItem>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
const MemoizeBackButton = React.memo(BackButton);
|
||||
|
||||
@@ -151,7 +119,8 @@ export const AppBar = () => {
|
||||
location.pathname.includes("server") ||
|
||||
location.pathname === "/player" ||
|
||||
location.pathname.includes("error") ||
|
||||
location.pathname === "/"
|
||||
location.pathname === "/" ||
|
||||
location.pathname.includes("settings")
|
||||
) {
|
||||
setDisplay(false);
|
||||
} else {
|
||||
@@ -290,6 +259,18 @@ export const AppBar = () => {
|
||||
</ListItemIcon>
|
||||
Settings
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
navigate({ to: "/settings/preferences" });
|
||||
setSettingsTabValue(1);
|
||||
handleMenuClose();
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<div className="material-symbols-rounded">tune</div>
|
||||
</ListItemIcon>
|
||||
Preferences
|
||||
</MenuItem>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
setSettingsDialogOpen(true);
|
||||
@@ -327,10 +308,16 @@ export const AppBar = () => {
|
||||
</List>
|
||||
<Divider variant="middle" />
|
||||
<List>
|
||||
<ListItemLink to="/home" icon="home" primary="Home" />
|
||||
<ListItemLink
|
||||
className="library-drawer-item"
|
||||
to="/home"
|
||||
icon="home"
|
||||
primary="Home"
|
||||
/>
|
||||
{libraries.isSuccess &&
|
||||
libraries.data?.Items?.map((library) => (
|
||||
<ListItemLink
|
||||
className="library-drawer-item"
|
||||
key={library.Id}
|
||||
to={`/library/${library.Id}`}
|
||||
icon={
|
||||
|
||||
@@ -34,6 +34,7 @@ import getSubtitle from "@/utils/methods/getSubtitles";
|
||||
import playbackProfile from "@/utils/playback-profiles";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { usePhotosPlayback } from "@/utils/store/photosPlayback";
|
||||
import { getDisplayPreferencesApi } from "@jellyfin/sdk/lib/utils/api/display-preferences-api";
|
||||
import { getMediaInfoApi } from "@jellyfin/sdk/lib/utils/api/media-info-api";
|
||||
import { getMediaSegmentsApi } from "@jellyfin/sdk/lib/utils/api/media-segments-api";
|
||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||
@@ -428,7 +429,7 @@ const PlayButton = ({
|
||||
episodeIndex: index,
|
||||
};
|
||||
},
|
||||
onSuccess: (result: PlayResult | null) => {
|
||||
onSuccess: async (result: PlayResult | null) => {
|
||||
if (!api) {
|
||||
console.error("API is not available");
|
||||
enqueueSnackbar("API is not available", { variant: "error" });
|
||||
@@ -450,6 +451,14 @@ const PlayButton = ({
|
||||
return;
|
||||
}
|
||||
|
||||
const displayPreferences = await getDisplayPreferencesApi(
|
||||
api,
|
||||
).getDisplayPreferences({
|
||||
userId: userId,
|
||||
displayPreferencesId: api.deviceInfo.id,
|
||||
client: "blink",
|
||||
});
|
||||
|
||||
if (audio) {
|
||||
// Album/Individual audio track playback
|
||||
const playbackUrl = generateAudioStreamUrl(
|
||||
@@ -531,6 +540,14 @@ const PlayButton = ({
|
||||
const startPosition =
|
||||
result?.item?.Items?.[episodeIndex].UserData?.PlaybackPositionTicks;
|
||||
|
||||
let initVolume = "1";
|
||||
if (
|
||||
displayPreferences.data.CustomPrefs?.RememberVolume &&
|
||||
displayPreferences.data.CustomPrefs?.Volume
|
||||
) {
|
||||
initVolume = displayPreferences.data.CustomPrefs?.Volume;
|
||||
}
|
||||
|
||||
playItem(
|
||||
itemName,
|
||||
episodeTitle,
|
||||
@@ -549,6 +566,7 @@ const PlayButton = ({
|
||||
subtitle,
|
||||
result?.introInfo,
|
||||
audio,
|
||||
Number(initVolume),
|
||||
);
|
||||
navigate({ to: "/player" });
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ const CardComponent = ({
|
||||
};
|
||||
|
||||
const { ref, inView } = useInView({
|
||||
threshold: 0,
|
||||
threshold: 0.1,
|
||||
});
|
||||
|
||||
return (
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
// Write a react component that included an MUI circluar progress element utilizing NProgrss
|
||||
|
||||
import { CircularProgress } from "@mui/material";
|
||||
import { useNProgress } from "@tanem/react-nprogress";
|
||||
import React from "react";
|
||||
|
||||
const CircularPageLoadingAnimation = () => {
|
||||
const { progress } = useNProgress({
|
||||
isAnimating: true,
|
||||
});
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
pointerEvents: "none",
|
||||
position: "absolute",
|
||||
top: "50%",
|
||||
left: "50%",
|
||||
transform: "translate(-50%, -50%)",
|
||||
zIndex: "10001",
|
||||
}}
|
||||
>
|
||||
<CircularProgress
|
||||
// variant="indeterminate"
|
||||
sx={{
|
||||
transitionDuration: "0.3s",
|
||||
transform: `scale(${progress})`,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default CircularPageLoadingAnimation;
|
||||
@@ -0,0 +1,37 @@
|
||||
import { ListItem, ListItemButton, ListItemText } from "@mui/material";
|
||||
import { Link, type ReactNode } from "@tanstack/react-router";
|
||||
import React from "react";
|
||||
|
||||
interface ListItemLinkProps {
|
||||
icon?: ReactNode;
|
||||
primary: string;
|
||||
to: string;
|
||||
className?: string;
|
||||
}
|
||||
export default function ListItemLink(props: ListItemLinkProps) {
|
||||
const { icon, primary, to, className } = props;
|
||||
|
||||
return (
|
||||
<li>
|
||||
{/* @ts-ignore */}
|
||||
<ListItem
|
||||
component={Link}
|
||||
activeClassName="active"
|
||||
className={className}
|
||||
to={to}
|
||||
>
|
||||
<ListItemButton
|
||||
style={{
|
||||
borderRadius: "100px",
|
||||
gap: "0.85em",
|
||||
color: "white",
|
||||
textDecoration: "none",
|
||||
}}
|
||||
>
|
||||
<div className="material-symbols-rounded">{icon}</div>
|
||||
<ListItemText primary={primary} />
|
||||
</ListItemButton>
|
||||
</ListItem>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
import type { CultureDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import {
|
||||
FormControlLabel,
|
||||
MenuItem,
|
||||
TextField,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import React, { useState } from "react";
|
||||
|
||||
const SettingOptionSelect = ({
|
||||
setting,
|
||||
options,
|
||||
userValue,
|
||||
}: {
|
||||
setting: { name: string; description: string };
|
||||
options: CultureDto[];
|
||||
userValue: string | null;
|
||||
}) => {
|
||||
const [value, setValue] = useState(
|
||||
userValue === "" ? "anyLanguage" : userValue,
|
||||
);
|
||||
return (
|
||||
<FormControlLabel
|
||||
value={value}
|
||||
control={
|
||||
<TextField select onChange={(e) => setValue(e.target.value)}>
|
||||
<MenuItem key={"anyLanguage"} value={"anyLanguage"}>
|
||||
Any Language
|
||||
</MenuItem>
|
||||
{options.map((option) => (
|
||||
<MenuItem
|
||||
key={option.ThreeLetterISOLanguageName}
|
||||
value={option.ThreeLetterISOLanguageName ?? "none"}
|
||||
>
|
||||
{option.DisplayName}
|
||||
</MenuItem>
|
||||
))}
|
||||
</TextField>
|
||||
}
|
||||
label={
|
||||
<div className="settings-option-info">
|
||||
<Typography variant="subtitle1" fontWeight={400}>
|
||||
{setting.name}
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="caption"
|
||||
className="settings-option-info-caption"
|
||||
>
|
||||
{setting.description}
|
||||
</Typography>
|
||||
</div>
|
||||
}
|
||||
labelPlacement="start"
|
||||
className="settings-option"
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default SettingOptionSelect;
|
||||
@@ -25,6 +25,8 @@ import logo from "@/assets/logo.png";
|
||||
|
||||
import { jellyfin, useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import { getDisplayPreferencesApi } from "@jellyfin/sdk/lib/utils/api/display-preferences-api";
|
||||
import { getLocalizationApi } from "@jellyfin/sdk/lib/utils/api/localization-api";
|
||||
import { getSystemApi } from "@jellyfin/sdk/lib/utils/api/system-api";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import "./settings.scss";
|
||||
@@ -46,6 +48,7 @@ import { relaunch } from "@tauri-apps/plugin-process";
|
||||
import { check } from "@tauri-apps/plugin-updater";
|
||||
import { useSnackbar } from "notistack";
|
||||
import SettingOption from "../settingOption";
|
||||
import SettingOptionSelect from "../settingOptionSelect";
|
||||
|
||||
const motionConfig = {
|
||||
initial: {
|
||||
@@ -65,6 +68,8 @@ const Settings = () => {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const createApi = useApiInContext((s) => s.createApi);
|
||||
|
||||
const user = useCentralStore((state) => state.currentUser);
|
||||
|
||||
const systemInfo = useQuery({
|
||||
queryKey: ["about", "systemInfo"],
|
||||
queryFn: async () => {
|
||||
@@ -98,8 +103,34 @@ const Settings = () => {
|
||||
enabled: open,
|
||||
});
|
||||
|
||||
const cultures = useQuery({
|
||||
queryKey: ["settings", "cultures"],
|
||||
queryFn: async () => {
|
||||
if (!api) return;
|
||||
const result = await getLocalizationApi(api).getCultures();
|
||||
return result.data;
|
||||
},
|
||||
enabled: open,
|
||||
});
|
||||
|
||||
const clientSettingsOnServer = useQuery({
|
||||
queryKey: ["settings", "clientSettings"],
|
||||
queryFn: async () => {
|
||||
if (!api) return;
|
||||
const result = await getDisplayPreferencesApi(api).getDisplayPreferences({
|
||||
client: "blink",
|
||||
userId: user?.Id,
|
||||
displayPreferencesId: api.deviceInfo.id,
|
||||
});
|
||||
return result.data;
|
||||
},
|
||||
enabled: open,
|
||||
});
|
||||
|
||||
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
// Server Management
|
||||
const [updating, setUpdating] = useState(false);
|
||||
const [addServerDialog, setAddServerDialog] = useState(false);
|
||||
const [serverIp, setServerIp] = useState("");
|
||||
@@ -203,7 +234,7 @@ const Settings = () => {
|
||||
open={open}
|
||||
fullWidth
|
||||
maxWidth="md"
|
||||
PaperProps={paperProps}
|
||||
slotProps={{ paper: paperProps }}
|
||||
hideBackdrop
|
||||
onClose={handleClose}
|
||||
>
|
||||
@@ -239,6 +270,17 @@ const Settings = () => {
|
||||
height: "48px",
|
||||
}}
|
||||
/>
|
||||
<Tab
|
||||
icon={<span className="material-symbols-rounded">tune</span>}
|
||||
iconPosition="start"
|
||||
value={3}
|
||||
label="Perferences"
|
||||
className="settings-tab"
|
||||
sx={{
|
||||
minHeight: "48px",
|
||||
height: "48px",
|
||||
}}
|
||||
/>
|
||||
<Tab
|
||||
icon={<span className="material-symbols-rounded">info</span>}
|
||||
iconPosition="start"
|
||||
@@ -411,6 +453,22 @@ const Settings = () => {
|
||||
</motion.div>
|
||||
)}
|
||||
|
||||
{/* Preferences */}
|
||||
{tabValue === 3 && cultures.isSuccess && (
|
||||
<div className="settings-container">
|
||||
<SettingOptionSelect
|
||||
setting={{
|
||||
name: "Preferred Audio Language",
|
||||
description: "Select your preferred audio language.",
|
||||
}}
|
||||
userValue={
|
||||
user?.Configuration?.AudioLanguagePreference ?? "anyLanguage"
|
||||
}
|
||||
options={cultures.data ?? []}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* About */}
|
||||
{tabValue === 10 && (
|
||||
<div className="settings-container settings-about">
|
||||
|
||||
+32
-27
@@ -5,6 +5,22 @@ import ReactDOM from "react-dom/client";
|
||||
// Import the generated route tree
|
||||
import { routeTree } from "./routeTree.gen";
|
||||
|
||||
import { ErrorBoundary } from "react-error-boundary";
|
||||
import { ErrorNotice } from "./components/notices/errorNotice/errorNotice";
|
||||
import { ApiProvider, useApiInContext } from "./utils/store/api";
|
||||
import { CentralProvider, useCentralStore } from "./utils/store/central";
|
||||
|
||||
export const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
networkMode: "always",
|
||||
},
|
||||
mutations: {
|
||||
networkMode: "always",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
//TODO: Need help implementing modal routes in TanStack Router
|
||||
// const SearchMask = createRouteMask({
|
||||
// routeTree,
|
||||
@@ -22,8 +38,11 @@ const router = createRouter({
|
||||
user: undefined,
|
||||
jellyfinSDK: undefined!,
|
||||
fetchCurrentUser: undefined!,
|
||||
queryClient,
|
||||
},
|
||||
defaultPreload: "intent",
|
||||
defaultPreloadStaleTime: 0,
|
||||
defaultViewTransition: true,
|
||||
// scrollRestoration: true,
|
||||
// scrollRestorationBehavior: "smooth",
|
||||
});
|
||||
@@ -35,22 +54,6 @@ declare module "@tanstack/react-router" {
|
||||
}
|
||||
}
|
||||
|
||||
import { ErrorBoundary } from "react-error-boundary";
|
||||
import { ErrorNotice } from "./components/notices/errorNotice/errorNotice";
|
||||
import { ApiProvider, useApiInContext } from "./utils/store/api";
|
||||
import { CentralProvider, useCentralStore } from "./utils/store/central";
|
||||
|
||||
export const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
networkMode: "always",
|
||||
},
|
||||
mutations: {
|
||||
networkMode: "always",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// biome-ignore lint/nursery/useComponentExportOnlyModules : This is a valid use case for a component export
|
||||
function ProviderWrapper() {
|
||||
const [api, createApi, jellyfinSDK] = useApiInContext((s) => [
|
||||
@@ -77,7 +80,14 @@ function ProviderWrapper() {
|
||||
return (
|
||||
<RouterProvider
|
||||
router={router}
|
||||
context={{ api, createApi, user, jellyfinSDK, fetchCurrentUser }}
|
||||
context={{
|
||||
api,
|
||||
createApi,
|
||||
user,
|
||||
jellyfinSDK,
|
||||
fetchCurrentUser,
|
||||
// queryClient,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -85,16 +95,11 @@ function ProviderWrapper() {
|
||||
ReactDOM.createRoot(document.getElementById("root")!).render(
|
||||
<React.StrictMode>
|
||||
<QueryClientProvider client={queryClient}>
|
||||
{/* TODO: Create a proper loading fallback component */}
|
||||
<ErrorBoundary FallbackComponent={ErrorNotice}>
|
||||
<Suspense fallback={<h1>Loading in main.tsx</h1>}>
|
||||
<CentralProvider>
|
||||
<ApiProvider>
|
||||
<ProviderWrapper />
|
||||
</ApiProvider>
|
||||
</CentralProvider>
|
||||
</Suspense>
|
||||
</ErrorBoundary>
|
||||
<CentralProvider>
|
||||
<ApiProvider>
|
||||
<ProviderWrapper />
|
||||
</ApiProvider>
|
||||
</CentralProvider>
|
||||
</QueryClientProvider>
|
||||
</React.StrictMode>,
|
||||
);
|
||||
|
||||
@@ -14,6 +14,7 @@ import { Route as rootRoute } from './routes/__root'
|
||||
import { Route as ApiImport } from './routes/_api'
|
||||
import { Route as IndexImport } from './routes/index'
|
||||
import { Route as ErrorCodeImport } from './routes/error/$code'
|
||||
import { Route as ApiSettingsImport } from './routes/_api/settings'
|
||||
import { Route as ApiLoginImport } from './routes/_api/login'
|
||||
import { Route as ApiSearchIndexImport } from './routes/_api/search/index'
|
||||
import { Route as ApiPlayerIndexImport } from './routes/_api/player/index'
|
||||
@@ -22,6 +23,7 @@ import { Route as ApiFavoriteIndexImport } from './routes/_api/favorite/index'
|
||||
import { Route as SetupServerListImport } from './routes/setup/server.list'
|
||||
import { Route as SetupServerErrorImport } from './routes/setup/server.error'
|
||||
import { Route as SetupServerAddImport } from './routes/setup/server.add'
|
||||
import { Route as ApiSettingsPreferencesImport } from './routes/_api/settings/preferences'
|
||||
import { Route as ApiSeriesIdImport } from './routes/_api/series/$id'
|
||||
import { Route as ApiPlaylistIdImport } from './routes/_api/playlist/$id'
|
||||
import { Route as ApiPlayerPhotosImport } from './routes/_api/player/photos'
|
||||
@@ -56,6 +58,12 @@ const ErrorCodeRoute = ErrorCodeImport.update({
|
||||
getParentRoute: () => rootRoute,
|
||||
} as any)
|
||||
|
||||
const ApiSettingsRoute = ApiSettingsImport.update({
|
||||
id: '/settings',
|
||||
path: '/settings',
|
||||
getParentRoute: () => ApiRoute,
|
||||
} as any)
|
||||
|
||||
const ApiLoginRoute = ApiLoginImport.update({
|
||||
id: '/login',
|
||||
path: '/login',
|
||||
@@ -104,6 +112,12 @@ const SetupServerAddRoute = SetupServerAddImport.update({
|
||||
getParentRoute: () => rootRoute,
|
||||
} as any)
|
||||
|
||||
const ApiSettingsPreferencesRoute = ApiSettingsPreferencesImport.update({
|
||||
id: '/preferences',
|
||||
path: '/preferences',
|
||||
getParentRoute: () => ApiSettingsRoute,
|
||||
} as any)
|
||||
|
||||
const ApiSeriesIdRoute = ApiSeriesIdImport.update({
|
||||
id: '/series/$id',
|
||||
path: '/series/$id',
|
||||
@@ -213,6 +227,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof ApiLoginImport
|
||||
parentRoute: typeof ApiImport
|
||||
}
|
||||
'/_api/settings': {
|
||||
id: '/_api/settings'
|
||||
path: '/settings'
|
||||
fullPath: '/settings'
|
||||
preLoaderRoute: typeof ApiSettingsImport
|
||||
parentRoute: typeof ApiImport
|
||||
}
|
||||
'/error/$code': {
|
||||
id: '/error/$code'
|
||||
path: '/error/$code'
|
||||
@@ -311,6 +332,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof ApiSeriesIdImport
|
||||
parentRoute: typeof ApiImport
|
||||
}
|
||||
'/_api/settings/preferences': {
|
||||
id: '/_api/settings/preferences'
|
||||
path: '/preferences'
|
||||
fullPath: '/settings/preferences'
|
||||
preLoaderRoute: typeof ApiSettingsPreferencesImport
|
||||
parentRoute: typeof ApiSettingsImport
|
||||
}
|
||||
'/setup/server/add': {
|
||||
id: '/setup/server/add'
|
||||
path: '/setup/server/add'
|
||||
@@ -388,8 +416,21 @@ const ApiLoginRouteWithChildren = ApiLoginRoute._addFileChildren(
|
||||
ApiLoginRouteChildren,
|
||||
)
|
||||
|
||||
interface ApiSettingsRouteChildren {
|
||||
ApiSettingsPreferencesRoute: typeof ApiSettingsPreferencesRoute
|
||||
}
|
||||
|
||||
const ApiSettingsRouteChildren: ApiSettingsRouteChildren = {
|
||||
ApiSettingsPreferencesRoute: ApiSettingsPreferencesRoute,
|
||||
}
|
||||
|
||||
const ApiSettingsRouteWithChildren = ApiSettingsRoute._addFileChildren(
|
||||
ApiSettingsRouteChildren,
|
||||
)
|
||||
|
||||
interface ApiRouteChildren {
|
||||
ApiLoginRoute: typeof ApiLoginRouteWithChildren
|
||||
ApiSettingsRoute: typeof ApiSettingsRouteWithChildren
|
||||
ApiAlbumIdRoute: typeof ApiAlbumIdRoute
|
||||
ApiArtistIdRoute: typeof ApiArtistIdRoute
|
||||
ApiBoxsetIdRoute: typeof ApiBoxsetIdRoute
|
||||
@@ -409,6 +450,7 @@ interface ApiRouteChildren {
|
||||
|
||||
const ApiRouteChildren: ApiRouteChildren = {
|
||||
ApiLoginRoute: ApiLoginRouteWithChildren,
|
||||
ApiSettingsRoute: ApiSettingsRouteWithChildren,
|
||||
ApiAlbumIdRoute: ApiAlbumIdRoute,
|
||||
ApiArtistIdRoute: ApiArtistIdRoute,
|
||||
ApiBoxsetIdRoute: ApiBoxsetIdRoute,
|
||||
@@ -432,6 +474,7 @@ export interface FileRoutesByFullPath {
|
||||
'/': typeof IndexRoute
|
||||
'': typeof ApiRouteWithChildren
|
||||
'/login': typeof ApiLoginRouteWithChildren
|
||||
'/settings': typeof ApiSettingsRouteWithChildren
|
||||
'/error/$code': typeof ErrorCodeRoute
|
||||
'/album/$id': typeof ApiAlbumIdRoute
|
||||
'/artist/$id': typeof ApiArtistIdRoute
|
||||
@@ -446,6 +489,7 @@ export interface FileRoutesByFullPath {
|
||||
'/player/photos': typeof ApiPlayerPhotosRoute
|
||||
'/playlist/$id': typeof ApiPlaylistIdRoute
|
||||
'/series/$id': typeof ApiSeriesIdRoute
|
||||
'/settings/preferences': typeof ApiSettingsPreferencesRoute
|
||||
'/setup/server/add': typeof SetupServerAddRoute
|
||||
'/setup/server/error': typeof SetupServerErrorRoute
|
||||
'/setup/server/list': typeof SetupServerListRoute
|
||||
@@ -460,6 +504,7 @@ export interface FileRoutesByTo {
|
||||
'/': typeof IndexRoute
|
||||
'': typeof ApiRouteWithChildren
|
||||
'/login': typeof ApiLoginRouteWithChildren
|
||||
'/settings': typeof ApiSettingsRouteWithChildren
|
||||
'/error/$code': typeof ErrorCodeRoute
|
||||
'/album/$id': typeof ApiAlbumIdRoute
|
||||
'/artist/$id': typeof ApiArtistIdRoute
|
||||
@@ -474,6 +519,7 @@ export interface FileRoutesByTo {
|
||||
'/player/photos': typeof ApiPlayerPhotosRoute
|
||||
'/playlist/$id': typeof ApiPlaylistIdRoute
|
||||
'/series/$id': typeof ApiSeriesIdRoute
|
||||
'/settings/preferences': typeof ApiSettingsPreferencesRoute
|
||||
'/setup/server/add': typeof SetupServerAddRoute
|
||||
'/setup/server/error': typeof SetupServerErrorRoute
|
||||
'/setup/server/list': typeof SetupServerListRoute
|
||||
@@ -489,6 +535,7 @@ export interface FileRoutesById {
|
||||
'/': typeof IndexRoute
|
||||
'/_api': typeof ApiRouteWithChildren
|
||||
'/_api/login': typeof ApiLoginRouteWithChildren
|
||||
'/_api/settings': typeof ApiSettingsRouteWithChildren
|
||||
'/error/$code': typeof ErrorCodeRoute
|
||||
'/_api/album/$id': typeof ApiAlbumIdRoute
|
||||
'/_api/artist/$id': typeof ApiArtistIdRoute
|
||||
@@ -503,6 +550,7 @@ export interface FileRoutesById {
|
||||
'/_api/player/photos': typeof ApiPlayerPhotosRoute
|
||||
'/_api/playlist/$id': typeof ApiPlaylistIdRoute
|
||||
'/_api/series/$id': typeof ApiSeriesIdRoute
|
||||
'/_api/settings/preferences': typeof ApiSettingsPreferencesRoute
|
||||
'/setup/server/add': typeof SetupServerAddRoute
|
||||
'/setup/server/error': typeof SetupServerErrorRoute
|
||||
'/setup/server/list': typeof SetupServerListRoute
|
||||
@@ -519,6 +567,7 @@ export interface FileRouteTypes {
|
||||
| '/'
|
||||
| ''
|
||||
| '/login'
|
||||
| '/settings'
|
||||
| '/error/$code'
|
||||
| '/album/$id'
|
||||
| '/artist/$id'
|
||||
@@ -533,6 +582,7 @@ export interface FileRouteTypes {
|
||||
| '/player/photos'
|
||||
| '/playlist/$id'
|
||||
| '/series/$id'
|
||||
| '/settings/preferences'
|
||||
| '/setup/server/add'
|
||||
| '/setup/server/error'
|
||||
| '/setup/server/list'
|
||||
@@ -546,6 +596,7 @@ export interface FileRouteTypes {
|
||||
| '/'
|
||||
| ''
|
||||
| '/login'
|
||||
| '/settings'
|
||||
| '/error/$code'
|
||||
| '/album/$id'
|
||||
| '/artist/$id'
|
||||
@@ -560,6 +611,7 @@ export interface FileRouteTypes {
|
||||
| '/player/photos'
|
||||
| '/playlist/$id'
|
||||
| '/series/$id'
|
||||
| '/settings/preferences'
|
||||
| '/setup/server/add'
|
||||
| '/setup/server/error'
|
||||
| '/setup/server/list'
|
||||
@@ -573,6 +625,7 @@ export interface FileRouteTypes {
|
||||
| '/'
|
||||
| '/_api'
|
||||
| '/_api/login'
|
||||
| '/_api/settings'
|
||||
| '/error/$code'
|
||||
| '/_api/album/$id'
|
||||
| '/_api/artist/$id'
|
||||
@@ -587,6 +640,7 @@ export interface FileRouteTypes {
|
||||
| '/_api/player/photos'
|
||||
| '/_api/playlist/$id'
|
||||
| '/_api/series/$id'
|
||||
| '/_api/settings/preferences'
|
||||
| '/setup/server/add'
|
||||
| '/setup/server/error'
|
||||
| '/setup/server/list'
|
||||
@@ -641,6 +695,7 @@ export const routeTree = rootRoute
|
||||
"filePath": "_api.tsx",
|
||||
"children": [
|
||||
"/_api/login",
|
||||
"/_api/settings",
|
||||
"/_api/album/$id",
|
||||
"/_api/artist/$id",
|
||||
"/_api/boxset/$id",
|
||||
@@ -667,6 +722,13 @@ export const routeTree = rootRoute
|
||||
"/_api/login/$userId/$userName"
|
||||
]
|
||||
},
|
||||
"/_api/settings": {
|
||||
"filePath": "_api/settings.tsx",
|
||||
"parent": "/_api",
|
||||
"children": [
|
||||
"/_api/settings/preferences"
|
||||
]
|
||||
},
|
||||
"/error/$code": {
|
||||
"filePath": "error/$code.tsx"
|
||||
},
|
||||
@@ -722,6 +784,10 @@ export const routeTree = rootRoute
|
||||
"filePath": "_api/series/$id.tsx",
|
||||
"parent": "/_api"
|
||||
},
|
||||
"/_api/settings/preferences": {
|
||||
"filePath": "_api/settings/preferences.tsx",
|
||||
"parent": "/_api/settings"
|
||||
},
|
||||
"/setup/server/add": {
|
||||
"filePath": "setup/server.add.tsx"
|
||||
},
|
||||
|
||||
@@ -23,7 +23,9 @@ import RouterLoading from "@/components/routerLoading";
|
||||
import Updater from "@/components/updater";
|
||||
import type { Api, Jellyfin } from "@jellyfin/sdk";
|
||||
import type { UserDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import type { QueryClient } from "@tanstack/react-query";
|
||||
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
||||
import { TanStackRouterDevtools } from "@tanstack/react-router-devtools";
|
||||
import { DndProvider } from "react-dnd";
|
||||
import { HTML5Backend } from "react-dnd-html5-backend";
|
||||
|
||||
@@ -33,6 +35,7 @@ type ApiContext = {
|
||||
user: UserDto | null | undefined;
|
||||
jellyfinSDK: Jellyfin;
|
||||
fetchCurrentUser: (api: Api | undefined) => Promise<void>;
|
||||
queryClient: QueryClient;
|
||||
};
|
||||
|
||||
export const Route = createRootRouteWithContext<ApiContext>()({
|
||||
@@ -54,7 +57,7 @@ export const Route = createRootRouteWithContext<ApiContext>()({
|
||||
<AudioPlayer />
|
||||
<Outlet />
|
||||
<ReactQueryDevtools />
|
||||
{/* <TanStackRouterDevtools /> */}
|
||||
<TanStackRouterDevtools />
|
||||
</SnackbarProvider>
|
||||
</ThemeProvider>
|
||||
</DndProvider>
|
||||
|
||||
@@ -57,25 +57,6 @@ type SortByObject = { title: string; value: string };
|
||||
type ViewObject = { title: string; value: BaseItemKind | "Artist" };
|
||||
// type allowedFilters = ["movies", "tvshows", "music", "books"];
|
||||
|
||||
const useWindowWidth = () => {
|
||||
const [width, setWidth] = React.useState(window.innerWidth);
|
||||
|
||||
React.useEffect(() => {
|
||||
const onResize = () => setWidth(window.innerWidth);
|
||||
|
||||
window.addEventListener("resize", onResize, {
|
||||
capture: false,
|
||||
passive: true,
|
||||
});
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("resize", onResize);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return width;
|
||||
};
|
||||
|
||||
export const Route = createFileRoute("/_api/library/$id")({
|
||||
component: Library,
|
||||
});
|
||||
@@ -725,36 +706,6 @@ function Library() {
|
||||
}
|
||||
}, [currentViewType]);
|
||||
|
||||
const cardSize = useMemo(
|
||||
() =>
|
||||
items.data?.Items?.[0]?.Type === BaseItemKind.MusicAlbum ||
|
||||
items.data?.Items?.[0]?.Type === BaseItemKind.Audio ||
|
||||
items.data?.Items?.[0]?.Type === BaseItemKind.Genre ||
|
||||
items.data?.Items?.[0]?.Type === BaseItemKind.MusicGenre ||
|
||||
items.data?.Items?.[0]?.Type === BaseItemKind.Studio ||
|
||||
items.data?.Items?.[0]?.Type === BaseItemKind.Playlist
|
||||
? 260
|
||||
: 356,
|
||||
[items.dataUpdatedAt],
|
||||
); // This sets the approx height of each card in library to estimate no of virtual rows to render
|
||||
const windowWidth = useWindowWidth();
|
||||
const itemsPerRow = useMemo(
|
||||
() => Math.max(1, Math.floor(windowWidth / 200)),
|
||||
[windowWidth],
|
||||
);
|
||||
const count = useMemo(
|
||||
() =>
|
||||
(items.data?.TotalRecordCount ?? 1) > itemsPerRow
|
||||
? Math.ceil((items.data?.TotalRecordCount ?? 1) / itemsPerRow)
|
||||
: 1,
|
||||
[itemsPerRow, items.dataUpdatedAt],
|
||||
);
|
||||
const virtualizer = useWindowVirtualizer({
|
||||
count,
|
||||
estimateSize: () => cardSize,
|
||||
overscan: 1,
|
||||
});
|
||||
|
||||
const rowVirtualizer = useWindowVirtualizer({
|
||||
count: items.data?.TotalRecordCount ?? 1,
|
||||
estimateSize: () => 80,
|
||||
|
||||
@@ -68,6 +68,7 @@ import BubbleSlider from "@/components/bubbleSlider";
|
||||
import videoPlayerReducer, {
|
||||
VideoPlayerActionKind,
|
||||
} from "@/utils/reducers/videoPlayerReducer";
|
||||
import { getDisplayPreferencesApi } from "@jellyfin/sdk/lib/utils/api/display-preferences-api";
|
||||
|
||||
const ticksDisplay = (ticks: number) => {
|
||||
const time = Math.round(ticks / 10000);
|
||||
@@ -161,6 +162,7 @@ function VideoPlayer() {
|
||||
mediaSource,
|
||||
playsessionId,
|
||||
mediaSegments,
|
||||
initVolume,
|
||||
] = usePlaybackStore((state) => [
|
||||
state.playbackStream,
|
||||
state.item,
|
||||
@@ -171,6 +173,7 @@ function VideoPlayer() {
|
||||
state.mediaSource,
|
||||
state.playsessionId,
|
||||
state.intro,
|
||||
state.volume,
|
||||
]);
|
||||
|
||||
const introInfo = mediaSegments?.Items?.find(
|
||||
@@ -198,7 +201,6 @@ function VideoPlayer() {
|
||||
const [showVolumeControl, setShowVolumeControl] = useState(false);
|
||||
|
||||
// Control States
|
||||
|
||||
const [
|
||||
{
|
||||
ref,
|
||||
@@ -219,7 +221,7 @@ function VideoPlayer() {
|
||||
isPlayerPlaying: true,
|
||||
isPlayerMuted: false,
|
||||
isPlayerFullscreen: false,
|
||||
playerVolume: 1,
|
||||
playerVolume: initVolume ?? 1,
|
||||
isSeeking: false,
|
||||
sliderSeek: startPosition,
|
||||
progress: startPosition,
|
||||
@@ -632,6 +634,25 @@ function VideoPlayer() {
|
||||
player.current?.seekTo(ticksToSec(next?.StartPositionTicks ?? 0));
|
||||
}, [progress, playsessionId]);
|
||||
|
||||
useEffect(() => {
|
||||
async function setVolumeInServer() {
|
||||
if (!api) return null;
|
||||
await getDisplayPreferencesApi(api).updateDisplayPreferences({
|
||||
userId: user?.Id,
|
||||
client: "blink",
|
||||
displayPreferencesId: api.deviceInfo.id,
|
||||
displayPreferencesDto: {
|
||||
CustomPrefs: {
|
||||
Volume: String(playerVolume),
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
if (user?.Id && initVolume !== playerVolume && initVolume !== undefined) {
|
||||
setVolumeInServer();
|
||||
}
|
||||
}, [playerVolume]);
|
||||
|
||||
return (
|
||||
<div className="video-player">
|
||||
<AnimatePresence>
|
||||
@@ -944,16 +965,18 @@ function VideoPlayer() {
|
||||
max={1}
|
||||
size="small"
|
||||
value={isPlayerMuted ? 0 : playerVolume}
|
||||
onChange={(_, newValue) => {
|
||||
Array.isArray(newValue)
|
||||
? dispatch({
|
||||
type: VideoPlayerActionKind.SET_PLAYER_VOLUME,
|
||||
payload: newValue[0],
|
||||
})
|
||||
: dispatch({
|
||||
type: VideoPlayerActionKind.SET_PLAYER_VOLUME,
|
||||
payload: newValue,
|
||||
});
|
||||
onChange={async (_, newValue) => {
|
||||
if (api && Array.isArray(newValue)) {
|
||||
dispatch({
|
||||
type: VideoPlayerActionKind.SET_PLAYER_VOLUME,
|
||||
payload: newValue[0],
|
||||
});
|
||||
} else {
|
||||
dispatch({
|
||||
type: VideoPlayerActionKind.SET_PLAYER_VOLUME,
|
||||
payload: newValue,
|
||||
});
|
||||
}
|
||||
if (newValue === 0)
|
||||
dispatch({
|
||||
type: VideoPlayerActionKind.SET_PLAYER_MUTED,
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
.settings {
|
||||
&-page {
|
||||
&-container {
|
||||
display: grid;
|
||||
grid-template-columns: 16em 1fr;
|
||||
padding: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
}
|
||||
&-scrollY {
|
||||
padding: 2em;
|
||||
}
|
||||
}
|
||||
&-form{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
justify-content: flex-start;
|
||||
gap: 1em;
|
||||
width: 100%;
|
||||
margin-top: 2em;
|
||||
}
|
||||
&-sidebar {
|
||||
// padding-top: 4.4em !important;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
background: rgb(0 0 0 / 0.4);
|
||||
border-right: 1px solid rgba(255, 255, 255, 0.12);
|
||||
// padding-top: 1em;s
|
||||
&-controls {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
gap: 0.5em;
|
||||
width: 100%;
|
||||
padding: 1em;
|
||||
}
|
||||
&-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
width: 100%;
|
||||
padding: 1em;
|
||||
flex-direction: row;
|
||||
gap: 1em;
|
||||
&-image {
|
||||
$size: 3em;
|
||||
width: $size;
|
||||
height: $size;
|
||||
border-radius: 50%;
|
||||
}
|
||||
}
|
||||
&-list-item {
|
||||
width: 100%;
|
||||
.MuiButtonBase-root {
|
||||
border-radius: 5px !important;
|
||||
}
|
||||
&.active .MuiButtonBase-root {
|
||||
--fill: 1;
|
||||
background: $clr-gradient-default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||
import {
|
||||
Link,
|
||||
Outlet,
|
||||
createFileRoute,
|
||||
useNavigate,
|
||||
} from "@tanstack/react-router";
|
||||
import React, { useCallback, useEffect } from "react";
|
||||
|
||||
import "./settings.scss";
|
||||
import BackButton from "@/components/buttons/backButton";
|
||||
import ListItemLink from "@/components/listItemLink";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import { Button, Divider, IconButton, List, Typography } from "@mui/material";
|
||||
|
||||
export const Route = createFileRoute("/_api/settings")({
|
||||
component: SettingsRoute,
|
||||
});
|
||||
|
||||
function SettingsRoute() {
|
||||
const setBackdrop = useBackdropStore((s) => s.setBackdrop);
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const user = useCentralStore((s) => s.currentUser);
|
||||
useEffect(() => {
|
||||
setBackdrop("", "none");
|
||||
});
|
||||
const navigate = useNavigate();
|
||||
const handleNavigateHome = useCallback(() => {
|
||||
navigate({ to: "/home" });
|
||||
}, []);
|
||||
return (
|
||||
<div className="settings-page-container">
|
||||
<div className="settings-sidebar">
|
||||
<div className="settings-sidebar-controls">
|
||||
<BackButton />
|
||||
<IconButton onClick={handleNavigateHome}>
|
||||
<span className="material-symbols-rounded">home</span>
|
||||
</IconButton>
|
||||
</div>
|
||||
<Divider flexItem />
|
||||
<div className="settings-sidebar-header">
|
||||
<img
|
||||
className="settings-sidebar-header-image"
|
||||
src={`${api?.basePath}/Users/${user?.Id}/Images/Primary`}
|
||||
alt="user"
|
||||
/>
|
||||
<div className="flex flex-column">
|
||||
<Typography variant="h6">{user?.Name}</Typography>
|
||||
<Typography variant="caption" style={{ opacity: 0.5 }}>
|
||||
{user?.Policy?.IsAdministrator ? "administrator" : "user"}
|
||||
</Typography>
|
||||
</div>
|
||||
</div>
|
||||
<Divider flexItem variant="middle" />
|
||||
<List
|
||||
component="nav"
|
||||
aria-label="main mailbox folders"
|
||||
className="settings-sidebar-list"
|
||||
style={{
|
||||
width: "100%",
|
||||
}}
|
||||
>
|
||||
<ListItemLink
|
||||
to="/settings/preferences"
|
||||
icon="tune"
|
||||
primary="Preferences"
|
||||
className="settings-sidebar-list-item"
|
||||
/>
|
||||
</List>
|
||||
</div>
|
||||
<Outlet />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,214 @@
|
||||
import {
|
||||
Button,
|
||||
FormControlLabel,
|
||||
MenuItem,
|
||||
Switch,
|
||||
TextField,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import React from "react";
|
||||
|
||||
import "../settings.scss";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import { getLocalizationApi } from "@jellyfin/sdk/lib/utils/api/localization-api";
|
||||
import { useQuery, useSuspenseQuery } from "@tanstack/react-query";
|
||||
|
||||
import CircularPageLoadingAnimation from "@/components/circularPageLoadingAnimation";
|
||||
// import { getDisplayPreferencesApi } from "@jellyfin/sdk/lib/utils/api/display-preferences-api";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { useForm } from "@tanstack/react-form";
|
||||
import { useSnackbar } from "notistack";
|
||||
|
||||
export const Route = createFileRoute("/_api/settings/preferences")({
|
||||
component: RouteComponent,
|
||||
pendingComponent: () => <CircularPageLoadingAnimation />,
|
||||
});
|
||||
|
||||
function RouteComponent() {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const user = useCentralStore((s) => s.currentUser);
|
||||
const cultures = useSuspenseQuery({
|
||||
queryKey: ["settings", "cultures"],
|
||||
queryFn: async () => {
|
||||
if (!api) return;
|
||||
const result = await getLocalizationApi(api).getCultures();
|
||||
return result.data;
|
||||
},
|
||||
});
|
||||
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
|
||||
const form = useForm({
|
||||
defaultValues: {
|
||||
preferredAudioLanguage:
|
||||
user?.Configuration?.AudioLanguagePreference ?? "anyLanguage",
|
||||
playDefaultAudioTrack: user?.Configuration?.PlayDefaultAudioTrack,
|
||||
},
|
||||
onSubmit: async (values) => {
|
||||
if (!api) return;
|
||||
await getUserApi(api).updateUserConfiguration({
|
||||
userId: user?.Id,
|
||||
userConfiguration: {
|
||||
AudioLanguagePreference: values.value.preferredAudioLanguage,
|
||||
PlayDefaultAudioTrack: values.value.playDefaultAudioTrack,
|
||||
},
|
||||
});
|
||||
// await getDisplayPreferencesApi(api).updateDisplayPreferences({
|
||||
// userId: user?.Id,
|
||||
// displayPreferencesId: api.deviceInfo.id,
|
||||
// client: "blink",
|
||||
// displayPreferencesDto: {
|
||||
// ...displayPreferences.data,
|
||||
// CustomPrefs: {
|
||||
// RememberVolume: JSON.stringify(values.value.rememberVolume),
|
||||
// },
|
||||
// },
|
||||
// });
|
||||
enqueueSnackbar("Settings saved", {
|
||||
variant: "success",
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="settings-page-scrollY">
|
||||
<Typography variant="h4">Preferences</Typography>
|
||||
{/* <form.Pro */}
|
||||
<form
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
form.handleSubmit();
|
||||
}}
|
||||
onError={() =>
|
||||
enqueueSnackbar("Error saving settings", { variant: "error" })
|
||||
}
|
||||
className="settings-form"
|
||||
>
|
||||
<form.Field
|
||||
name="preferredAudioLanguage"
|
||||
// children={}
|
||||
>
|
||||
{(field) => {
|
||||
return (
|
||||
<FormControlLabel
|
||||
control={
|
||||
<TextField
|
||||
defaultValue={field.state.value}
|
||||
select
|
||||
hiddenLabel
|
||||
variant="filled"
|
||||
onChange={(e) => field.handleChange(e.target.value)}
|
||||
onBlur={field.handleBlur}
|
||||
style={{
|
||||
width: "18em",
|
||||
}}
|
||||
>
|
||||
<MenuItem key={"anyLanguage"} value={"anyLanguage"}>
|
||||
Any Language
|
||||
</MenuItem>
|
||||
{cultures.data?.map((option) => (
|
||||
<MenuItem
|
||||
key={option.ThreeLetterISOLanguageName}
|
||||
value={option.ThreeLetterISOLanguageName ?? "none"}
|
||||
>
|
||||
{option.DisplayName}
|
||||
</MenuItem>
|
||||
))}
|
||||
</TextField>
|
||||
}
|
||||
label={
|
||||
<div className="settings-option-info">
|
||||
<Typography variant="subtitle1" fontWeight={400}>
|
||||
Preferred Audio Language
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="caption"
|
||||
className="settings-option-info-caption"
|
||||
>
|
||||
Choose your preferred audio language.
|
||||
</Typography>
|
||||
</div>
|
||||
}
|
||||
labelPlacement="start"
|
||||
className="settings-option"
|
||||
/>
|
||||
);
|
||||
}}
|
||||
</form.Field>
|
||||
<form.Field
|
||||
name="playDefaultAudioTrack"
|
||||
// children={}
|
||||
>
|
||||
{(field) => {
|
||||
return (
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Switch
|
||||
checked={field.state.value}
|
||||
onChange={(_, checked) => field.handleChange(checked)}
|
||||
onBlur={field.handleBlur}
|
||||
/>
|
||||
}
|
||||
label={
|
||||
<div className="settings-option-info">
|
||||
<Typography variant="subtitle1" fontWeight={400}>
|
||||
Play default audio track regardless of language
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="caption"
|
||||
className="settings-option-info-caption"
|
||||
>
|
||||
Play the default audio track of the media item, even if it
|
||||
does not match your preferred audio language.
|
||||
</Typography>
|
||||
</div>
|
||||
}
|
||||
labelPlacement="start"
|
||||
className="settings-option"
|
||||
/>
|
||||
);
|
||||
}}
|
||||
</form.Field>
|
||||
<Button type="submit" size="large" variant="contained">
|
||||
Save
|
||||
</Button>
|
||||
</form>
|
||||
{/* <FormControlLabel
|
||||
value={currentCulture}
|
||||
control={
|
||||
<TextField select onChange={(e) => setCurrentCulture(e.target.value)}>
|
||||
<MenuItem key={"anyLanguage"} value={"anyLanguage"}>
|
||||
Any Language
|
||||
</MenuItem>
|
||||
{cultures.data?.map((option) => (
|
||||
<MenuItem
|
||||
key={option.ThreeLetterISOLanguageName}
|
||||
value={option.ThreeLetterISOLanguageName ?? "none"}
|
||||
>
|
||||
{option.DisplayName}
|
||||
</MenuItem>
|
||||
))}
|
||||
</TextField>
|
||||
}
|
||||
label={
|
||||
<div className="settings-option-info">
|
||||
<Typography variant="subtitle1" fontWeight={400}>
|
||||
{setting.name}
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="caption"
|
||||
className="settings-option-info-caption"
|
||||
>
|
||||
{setting.description}
|
||||
</Typography>
|
||||
</div>
|
||||
}
|
||||
labelPlacement="start"
|
||||
className="settings-option"
|
||||
/> */}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import { createFileRoute, redirect } from "@tanstack/react-router";
|
||||
|
||||
export const Route = createFileRoute("/")({
|
||||
beforeLoad: async () => {
|
||||
console.log("Hello");
|
||||
const currentServerId = await getDefaultServer();
|
||||
const userOnDisk = await getUser();
|
||||
if (currentServerId) {
|
||||
|
||||
@@ -86,6 +86,17 @@ body {
|
||||
opacity: 0.35;
|
||||
}
|
||||
|
||||
/**
|
||||
* Page transitions
|
||||
*/
|
||||
:root{
|
||||
view-transition-name: fadeingPage;
|
||||
}
|
||||
|
||||
::view-transition-group(fadeingPage) {
|
||||
animation-duration: .3s;
|
||||
}
|
||||
|
||||
.fadeIn {
|
||||
animation: 0.5s fadeInPage forwards;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ type PlaybackStore = {
|
||||
item: BaseItemDto | null;
|
||||
playsessionId: string | undefined | null;
|
||||
intro: MediaSegmentDtoQueryResult | undefined;
|
||||
volume: number | undefined;
|
||||
};
|
||||
|
||||
export const usePlaybackStore = createWithEqualityFn<PlaybackStore>(
|
||||
@@ -65,6 +66,7 @@ export const usePlaybackStore = createWithEqualityFn<PlaybackStore>(
|
||||
item: null,
|
||||
playsessionId: "",
|
||||
intro: undefined,
|
||||
volume: 1,
|
||||
}),
|
||||
shallow,
|
||||
);
|
||||
@@ -87,6 +89,7 @@ export const playItem = (
|
||||
subtitle: subtitlePlaybackInfo | undefined,
|
||||
intro: MediaSegmentDtoQueryResult | undefined,
|
||||
audio: audioPlaybackInfo,
|
||||
volume: number | undefined = 1,
|
||||
) => {
|
||||
console.log({
|
||||
itemName,
|
||||
@@ -106,6 +109,7 @@ export const playItem = (
|
||||
item,
|
||||
playsessionId,
|
||||
intro,
|
||||
volume,
|
||||
});
|
||||
|
||||
if (!queue) {
|
||||
@@ -138,6 +142,7 @@ export const playItem = (
|
||||
item,
|
||||
playsessionId,
|
||||
intro,
|
||||
volume,
|
||||
});
|
||||
setQueue(queue, queueItemIndex);
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user