refactor: improve UI components
This commit is contained in:
14 files changed
+220
-246
No files matched your search
@@ -1,17 +1,17 @@
|
||||
import { setServer } from "@/utils/storage/servers";
|
||||
import { jellyfin } from "@/utils/store/api";
|
||||
import { LoadingButton } from "@mui/lab";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
TextField,
|
||||
InputBase,
|
||||
Stack,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
import { enqueueSnackbar } from "notistack";
|
||||
import React, { useState } from "react";
|
||||
import { setServer } from "@/utils/storage/servers";
|
||||
import { jellyfin } from "@/utils/store/api";
|
||||
|
||||
type AddServerDialogProps = {
|
||||
open: boolean;
|
||||
@@ -64,72 +64,98 @@ export default function AddServerDialog(props: AddServerDialogProps) {
|
||||
return (
|
||||
<Dialog
|
||||
open={open}
|
||||
onClose={() => setAddServerDialog(false)}
|
||||
hideBackdrop={Boolean(hideBackdrop)}
|
||||
fullWidth
|
||||
maxWidth="sm"
|
||||
disableScrollLock={true}
|
||||
PaperProps={{
|
||||
sx: {
|
||||
backgroundColor: "rgba(20, 20, 30, 0.7)",
|
||||
backdropFilter: "blur(24px) saturate(180%)",
|
||||
backgroundImage:
|
||||
"linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0))",
|
||||
border: "1px solid rgba(255, 255, 255, 0.08)",
|
||||
boxShadow: "0 20px 50px rgba(0,0,0,0.5)",
|
||||
borderRadius: 4,
|
||||
overflow: "hidden",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<DialogTitle variant="h4" align="center" mb={1}>
|
||||
Add Server
|
||||
</DialogTitle>
|
||||
<DialogContent className="settings-server-add">
|
||||
<TextField
|
||||
variant="filled"
|
||||
label="Address"
|
||||
fullWidth
|
||||
onChange={(e) => setServerIp(e.target.value)}
|
||||
/>
|
||||
</DialogContent>
|
||||
<DialogActions
|
||||
style={{
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
padding: "1em",
|
||||
gap: "1em",
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
variant="contained"
|
||||
startIcon={
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{
|
||||
marginRight: "0.25em",
|
||||
fontVariationSettings:
|
||||
'"FILL" 1, "wght" 300, "GRAD" 25, "opsz" 40',
|
||||
}}
|
||||
>
|
||||
cancel
|
||||
</span>
|
||||
}
|
||||
color="error"
|
||||
onClick={() => setAddServerDialog(false)}
|
||||
<Stack p={4} spacing={3}>
|
||||
<Stack spacing={1} alignItems="center">
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{
|
||||
fontSize: "48px",
|
||||
color: "var(--mui-palette-primary-main)",
|
||||
}}
|
||||
>
|
||||
add_to_queue
|
||||
</span>
|
||||
<Typography variant="h5" fontWeight="bold" textAlign="center">
|
||||
Connect to Server
|
||||
</Typography>
|
||||
<Typography variant="body2" color="text.secondary" textAlign="center">
|
||||
Enter your Jellyfin server address to continue
|
||||
</Typography>
|
||||
</Stack>
|
||||
|
||||
<Box
|
||||
sx={{
|
||||
p: "2px 16px",
|
||||
bgcolor: "rgba(0,0,0,0.2)",
|
||||
borderRadius: 2,
|
||||
border: "1px solid rgba(255,255,255,0.05)",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
gap: 2,
|
||||
"&:focus-within": {
|
||||
border: "1px solid var(--mui-palette-primary-main)",
|
||||
bgcolor: "rgba(0,0,0,0.3)",
|
||||
},
|
||||
transition: "all 0.2s",
|
||||
}}
|
||||
>
|
||||
Close
|
||||
</Button>
|
||||
{/* @ts-ignore */}
|
||||
<LoadingButton
|
||||
startIcon={
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{
|
||||
marginRight: "0.25em",
|
||||
fontVariationSettings:
|
||||
'"FILL" 1, "wght" 300, "GRAD" 25, "opsz" 40',
|
||||
}}
|
||||
>
|
||||
add_circle
|
||||
</span>
|
||||
}
|
||||
variant="contained"
|
||||
loading={addServer.isPending}
|
||||
loadingPosition="start"
|
||||
onClick={addServer.mutate}
|
||||
color="success"
|
||||
>
|
||||
Add
|
||||
</LoadingButton>
|
||||
</DialogActions>
|
||||
<span className="material-symbols-rounded" style={{ opacity: 0.5 }}>
|
||||
dns
|
||||
</span>
|
||||
<InputBase
|
||||
placeholder="https://jellyfin.example.com"
|
||||
fullWidth
|
||||
value={serverIp}
|
||||
onChange={(e) => setServerIp(e.target.value)}
|
||||
sx={{ py: 1.5 }}
|
||||
autoFocus
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") {
|
||||
addServer.mutate();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
<Stack direction="row" spacing={2} justifyContent="flex-end" pt={1}>
|
||||
<Button
|
||||
onClick={() => setAddServerDialog(false)}
|
||||
color="inherit"
|
||||
variant="text"
|
||||
sx={{ borderRadius: 2 }}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<LoadingButton
|
||||
loading={addServer.isPending}
|
||||
onClick={() => addServer.mutate()}
|
||||
variant="contained"
|
||||
color="primary"
|
||||
sx={{ borderRadius: 2, px: 3 }}
|
||||
disabled={!serverIp}
|
||||
>
|
||||
Connect
|
||||
</LoadingButton>
|
||||
</Stack>
|
||||
</Stack>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -16,15 +16,20 @@
|
||||
&::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
backdrop-filter: blur(40px);
|
||||
inset: -0.35em;
|
||||
pointer-events: none;
|
||||
border-radius: inherit;
|
||||
box-shadow: 0 0 25px rgb(0 0 0 / 0.45);
|
||||
background: rgb(0 0 0 / 0.4);
|
||||
|
||||
// Glass styling matching Search Dialog
|
||||
background-color: rgba(20, 20, 30, 0.7);
|
||||
backdrop-filter: blur(24px) saturate(180%);
|
||||
background-image: linear-gradient(rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0));
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
|
||||
|
||||
opacity: 0;
|
||||
z-index: -1;
|
||||
transition: opacity $transition-time-fast;
|
||||
transition: all $transition-time-fast;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,11 +130,11 @@ export const AppBar = () => {
|
||||
>
|
||||
<div className="flex flex-row" style={{ gap: "0.6em" }}>
|
||||
<IconButton onClick={handleDrawerOpen}>
|
||||
<div className="material-symbols-rounded">menu</div>
|
||||
<span className="material-symbols-rounded">menu</span>
|
||||
</IconButton>
|
||||
<MemoizeBackButton />
|
||||
<IconButton onClick={handleNavigateToHome}>
|
||||
<div
|
||||
<span
|
||||
className={
|
||||
location.pathname === "/home"
|
||||
? "material-symbols-rounded fill"
|
||||
@@ -142,16 +142,16 @@ export const AppBar = () => {
|
||||
}
|
||||
>
|
||||
home
|
||||
</div>
|
||||
</span>
|
||||
</IconButton>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-row" style={{ gap: "0.6em" }}>
|
||||
<IconButton onClick={toggleSearchDialog}>
|
||||
<div className="material-symbols-rounded">search</div>
|
||||
<span className="material-symbols-rounded">search</span>
|
||||
</IconButton>
|
||||
<IconButton onClick={handleNavigateToFavorite}>
|
||||
<div className="material-symbols-rounded">favorite</div>
|
||||
<span className="material-symbols-rounded">favorite</span>
|
||||
</IconButton>
|
||||
<UserAvatarMenu />
|
||||
</div>
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
import React from "react";
|
||||
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import type { UserItemDataDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import { getUserLibraryApi } from "@jellyfin/sdk/lib/utils/api/user-library-api";
|
||||
import { pink } from "@mui/material/colors";
|
||||
import IconButton from "@mui/material/IconButton";
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { useSnackbar } from "notistack";
|
||||
import React from "react";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
|
||||
export default function LikeButton({
|
||||
itemId,
|
||||
@@ -78,24 +76,24 @@ export default function LikeButton({
|
||||
transition: "opacity 250ms",
|
||||
}}
|
||||
>
|
||||
<div
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={
|
||||
isFavorite
|
||||
? {
|
||||
//@ts-ignore
|
||||
//@ts-expect-error
|
||||
"--fill": mutation.isPending ? 0 : 1,
|
||||
color: mutation.isPending ? "white" : pink.A700,
|
||||
}
|
||||
: {
|
||||
//@ts-ignore
|
||||
//@ts-expect-error
|
||||
"--fill": mutation.isPending ? 1 : 0,
|
||||
color: mutation.isPending ? pink.A700 : "white",
|
||||
}
|
||||
}
|
||||
>
|
||||
favorite
|
||||
</div>
|
||||
</span>
|
||||
</IconButton>
|
||||
);
|
||||
}
|
||||
@@ -263,14 +263,14 @@ const PlayButton = ({
|
||||
}
|
||||
{...buttonProps}
|
||||
>
|
||||
<div
|
||||
<span
|
||||
className="material-symbols-rounded em-4 fill"
|
||||
style={{
|
||||
fontSize: "3em",
|
||||
}}
|
||||
>
|
||||
play_arrow
|
||||
</div>
|
||||
</span>
|
||||
</Fab>
|
||||
);
|
||||
}
|
||||
@@ -295,7 +295,7 @@ const PlayButton = ({
|
||||
}
|
||||
}}
|
||||
startIcon={
|
||||
<div
|
||||
<span
|
||||
className="material-symbols-rounded fill"
|
||||
style={{
|
||||
zIndex: 1,
|
||||
@@ -303,7 +303,7 @@ const PlayButton = ({
|
||||
}}
|
||||
>
|
||||
play_arrow
|
||||
</div>
|
||||
</span>
|
||||
}
|
||||
{...buttonProps}
|
||||
sx={{
|
||||
@@ -384,7 +384,7 @@ const PlayButton = ({
|
||||
item.Type === "Episode" ? handleClick(e, item.Id) : handleClick(e)
|
||||
}
|
||||
startIcon={
|
||||
<div
|
||||
<span
|
||||
className="material-symbols-rounded fill"
|
||||
style={{
|
||||
zIndex: 1,
|
||||
@@ -392,7 +392,7 @@ const PlayButton = ({
|
||||
}}
|
||||
>
|
||||
play_arrow
|
||||
</div>
|
||||
</span>
|
||||
}
|
||||
{...buttonProps}
|
||||
sx={{
|
||||
|
||||
@@ -160,13 +160,21 @@ const QueueButton = () => {
|
||||
open={open}
|
||||
onClose={() => setOpen(false)}
|
||||
PaperProps={{
|
||||
className: "glass",
|
||||
sx: {
|
||||
width: 450,
|
||||
maxWidth: "100%",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
bgcolor: "background.default",
|
||||
backgroundImage: "none",
|
||||
borderLeft: "1px solid rgba(255, 255, 255, 0.08)",
|
||||
},
|
||||
}}
|
||||
ModalProps={{
|
||||
BackdropProps: {
|
||||
sx: {
|
||||
backgroundColor: "rgba(0, 0, 0, 0.2)",
|
||||
backdropFilter: "blur(4px)",
|
||||
},
|
||||
},
|
||||
}}
|
||||
>
|
||||
@@ -179,9 +187,10 @@ const QueueButton = () => {
|
||||
position: "sticky",
|
||||
top: 0,
|
||||
zIndex: 20,
|
||||
bgcolor: "background.default",
|
||||
borderBottom: "1px solid",
|
||||
borderColor: "divider",
|
||||
borderColor: "rgba(255, 255, 255, 0.08)",
|
||||
backgroundColor: "rgba(20, 20, 30, 0.4)",
|
||||
backdropFilter: "blur(12px)",
|
||||
}}
|
||||
>
|
||||
<Box display="flex" alignItems="center" gap={1}>
|
||||
@@ -194,7 +203,7 @@ const QueueButton = () => {
|
||||
sx={{
|
||||
ml: 1,
|
||||
fontWeight: 600,
|
||||
bgcolor: "action.hover",
|
||||
bgcolor: "rgba(255, 255, 255, 0.08)",
|
||||
px: 1,
|
||||
py: 0.5,
|
||||
borderRadius: 2,
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
import useInterval from "@/utils/hooks/useInterval";
|
||||
import { saveUser } from "@/utils/storage/user";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { getQuickConnectApi } from "@jellyfin/sdk/lib/utils/api/quick-connect-api";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { LoadingButton, type LoadingButtonProps } from "@mui/lab";
|
||||
@@ -22,6 +19,9 @@ import { useNavigate } from "@tanstack/react-router";
|
||||
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
|
||||
import { useSnackbar } from "notistack";
|
||||
import React, { useCallback, useState } from "react";
|
||||
import useInterval from "@/utils/hooks/useInterval";
|
||||
import { saveUser } from "@/utils/storage/user";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
|
||||
const Transition = React.forwardRef(function Transition(
|
||||
props: TransitionProps & {
|
||||
@@ -185,6 +185,7 @@ const QuickConnectButton = (props: LoadingButtonProps) => {
|
||||
fullWidth
|
||||
maxWidth="xs"
|
||||
TransitionComponent={Transition}
|
||||
PaperProps={{ className: "glass", sx: { borderRadius: "24px" } }}
|
||||
>
|
||||
<DialogContent
|
||||
style={{
|
||||
|
||||
@@ -23,6 +23,7 @@ const TrailerButton = (props: TrailerButtonType) => {
|
||||
fullWidth
|
||||
open={dialog}
|
||||
PaperProps={{
|
||||
className: "glass",
|
||||
style: {
|
||||
overflow: "hidden",
|
||||
},
|
||||
|
||||
@@ -82,12 +82,13 @@
|
||||
top: 0;
|
||||
z-index: 10;
|
||||
opacity: 0;
|
||||
transition: opacity $transition-time-default;
|
||||
transition: all $transition-time-default;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: flex-end;
|
||||
padding: 0.5em;
|
||||
background: rgb(0 0 0 / 0.6);
|
||||
background: rgba(20, 20, 30, 0.6);
|
||||
backdrop-filter: blur(12px);
|
||||
}
|
||||
&:hover,
|
||||
&:focus,
|
||||
|
||||
@@ -164,9 +164,19 @@ export const FiltersDialog: React.FC<FiltersDialogProps> = React.memo(
|
||||
const restoreGenres = () => setLocalGenreIds(initialGenres);
|
||||
|
||||
return (
|
||||
<Dialog open={open} onClose={onClose} fullWidth maxWidth="sm" keepMounted>
|
||||
<Dialog
|
||||
open={open}
|
||||
onClose={onClose}
|
||||
fullWidth
|
||||
maxWidth="sm"
|
||||
keepMounted
|
||||
PaperProps={{ className: "glass", sx: { borderRadius: "24px" } }}
|
||||
>
|
||||
<DialogTitle>Filters</DialogTitle>
|
||||
<DialogContent dividers>
|
||||
<DialogContent
|
||||
dividers
|
||||
sx={{ borderColor: "rgba(255, 255, 255, 0.1)" }}
|
||||
>
|
||||
<Stack spacing={1.25}>
|
||||
<Accordion
|
||||
disableGutters
|
||||
@@ -186,7 +196,7 @@ export const FiltersDialog: React.FC<FiltersDialogProps> = React.memo(
|
||||
"& .MuiAccordionSummary-content": { my: 0 },
|
||||
}}
|
||||
expandIcon={
|
||||
<div className="material-symbols-rounded">expand_more</div>
|
||||
<span className="material-symbols-rounded">expand_more</span>
|
||||
}
|
||||
>
|
||||
<Typography variant="subtitle2">General</Typography>
|
||||
@@ -236,7 +246,9 @@ export const FiltersDialog: React.FC<FiltersDialogProps> = React.memo(
|
||||
"& .MuiAccordionSummary-content": { my: 0 },
|
||||
}}
|
||||
expandIcon={
|
||||
<div className="material-symbols-rounded">expand_more</div>
|
||||
<span className="material-symbols-rounded">
|
||||
expand_more
|
||||
</span>
|
||||
}
|
||||
>
|
||||
<Typography variant="subtitle2">Video features</Typography>
|
||||
@@ -288,7 +300,9 @@ export const FiltersDialog: React.FC<FiltersDialogProps> = React.memo(
|
||||
"& .MuiAccordionSummary-content": { my: 0 },
|
||||
}}
|
||||
expandIcon={
|
||||
<div className="material-symbols-rounded">expand_more</div>
|
||||
<span className="material-symbols-rounded">
|
||||
expand_more
|
||||
</span>
|
||||
}
|
||||
>
|
||||
<Typography variant="subtitle2">Resolution</Typography>
|
||||
@@ -334,7 +348,9 @@ export const FiltersDialog: React.FC<FiltersDialogProps> = React.memo(
|
||||
"& .MuiAccordionSummary-content": { my: 0 },
|
||||
}}
|
||||
expandIcon={
|
||||
<div className="material-symbols-rounded">expand_more</div>
|
||||
<span className="material-symbols-rounded">
|
||||
expand_more
|
||||
</span>
|
||||
}
|
||||
>
|
||||
<Typography variant="subtitle2">Media type</Typography>
|
||||
@@ -383,7 +399,9 @@ export const FiltersDialog: React.FC<FiltersDialogProps> = React.memo(
|
||||
"& .MuiAccordionSummary-content": { my: 0 },
|
||||
}}
|
||||
expandIcon={
|
||||
<div className="material-symbols-rounded">expand_more</div>
|
||||
<span className="material-symbols-rounded">
|
||||
expand_more
|
||||
</span>
|
||||
}
|
||||
>
|
||||
<Typography variant="subtitle2">Genres</Typography>
|
||||
@@ -475,7 +493,7 @@ export const FiltersDialogTrigger: React.FC = () => {
|
||||
onClick={() => setOpen(true)}
|
||||
aria-label="Open filters dialog"
|
||||
>
|
||||
<div
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{ position: "relative" }}
|
||||
>
|
||||
@@ -498,7 +516,7 @@ export const FiltersDialogTrigger: React.FC = () => {
|
||||
{activeCount}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</span>
|
||||
</IconButton>
|
||||
</Tooltip>
|
||||
<FiltersDialog open={open} onClose={() => setOpen(false)} />
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
|
||||
import {
|
||||
alpha,
|
||||
Box,
|
||||
IconButton,
|
||||
ListItem,
|
||||
@@ -94,16 +95,23 @@ const QueueListItem = ({
|
||||
}
|
||||
sx={{
|
||||
opacity: active ? 1 : 1,
|
||||
bgcolor: active ? "transparent" : "background.paper",
|
||||
bgcolor: active ? "rgba(255, 255, 255, 0.1)" : "rgba(0,0,0,0.2)",
|
||||
borderRadius: 3,
|
||||
mb: 0,
|
||||
transition: "all 0.2s ease",
|
||||
border: active ? "none" : "1px solid",
|
||||
borderColor: "divider",
|
||||
border: "1px solid",
|
||||
borderColor: active
|
||||
? "rgba(255, 255, 255, 0.2)"
|
||||
: "rgba(255,255,255,0.05)",
|
||||
"&:hover": {
|
||||
bgcolor: active ? "transparent" : "action.hover",
|
||||
bgcolor: active
|
||||
? "rgba(255, 255, 255, 0.15)"
|
||||
: "rgba(255,255,255,0.05)",
|
||||
transform: active ? "none" : "translateY(-2px)",
|
||||
boxShadow: active ? "none" : 2,
|
||||
borderColor: active
|
||||
? "rgba(255, 255, 255, 0.3)"
|
||||
: "rgba(255,255,255,0.2)",
|
||||
boxShadow: active ? "none" : "0 4px 12px rgba(0,0,0,0.2)",
|
||||
},
|
||||
pr: onDelete ? 6 : 2,
|
||||
...sx,
|
||||
@@ -117,7 +125,7 @@ const QueueListItem = ({
|
||||
marginRight: 12,
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
opacity: 0.3,
|
||||
opacity: 0.5,
|
||||
transition: "opacity 0.2s",
|
||||
}}
|
||||
className="drag-handle"
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import useSettingsStore, {
|
||||
setSettingsDialogOpen,
|
||||
setSettingsTabValue,
|
||||
} from "@/utils/store/settings";
|
||||
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 {
|
||||
Button,
|
||||
Chip,
|
||||
@@ -18,19 +17,25 @@ import {
|
||||
TextField,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { AnimatePresence, motion } from "motion/react";
|
||||
import React, { useState, useMemo, useCallback } from "react";
|
||||
|
||||
import React, { useCallback, useMemo, useState } from "react";
|
||||
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 useSettingsStore, {
|
||||
setSettingsDialogOpen,
|
||||
setSettingsTabValue,
|
||||
} from "@/utils/store/settings";
|
||||
import "./settings.scss";
|
||||
|
||||
import type { RecommendedServerInfo } from "@jellyfin/sdk";
|
||||
import { LoadingButton } from "@mui/lab";
|
||||
import { red } from "@mui/material/colors";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import { relaunch } from "@tauri-apps/plugin-process";
|
||||
import { check } from "@tauri-apps/plugin-updater";
|
||||
import { useSnackbar } from "notistack";
|
||||
import {
|
||||
delServer,
|
||||
getAllServers,
|
||||
@@ -40,13 +45,7 @@ import {
|
||||
} from "@/utils/storage/servers";
|
||||
import { allSettings } from "@/utils/storage/settings";
|
||||
import { delUser } from "@/utils/storage/user";
|
||||
import type { RecommendedServerInfo } from "@jellyfin/sdk";
|
||||
import { LoadingButton } from "@mui/lab";
|
||||
import { red } from "@mui/material/colors";
|
||||
import { useNavigate } from "@tanstack/react-router";
|
||||
import { relaunch } from "@tauri-apps/plugin-process";
|
||||
import { check } from "@tauri-apps/plugin-updater";
|
||||
import { useSnackbar } from "notistack";
|
||||
import AddServerDialog from "../addServerDialog";
|
||||
import SettingOption from "../settingOption";
|
||||
import SettingOptionSelect from "../settingOptionSelect";
|
||||
|
||||
@@ -64,12 +63,12 @@ const Settings = () => {
|
||||
state.dialogOpen,
|
||||
state.tabValue,
|
||||
]);
|
||||
|
||||
|
||||
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 () => {
|
||||
@@ -83,7 +82,9 @@ const Settings = () => {
|
||||
const navigate = useNavigate();
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
|
||||
const [applicationVersion] = useCentralStore((state) => [state.clientVersion]);
|
||||
const [applicationVersion] = useCentralStore((state) => [
|
||||
state.clientVersion,
|
||||
]);
|
||||
|
||||
const serversOnDisk = useQuery({
|
||||
queryKey: ["settings", "serversOnDisk"],
|
||||
@@ -113,7 +114,7 @@ const Settings = () => {
|
||||
enabled: open,
|
||||
});
|
||||
|
||||
const clientSettingsOnServer = useQuery({
|
||||
const _clientSettingsOnServer = useQuery({
|
||||
queryKey: ["settings", "clientSettings"],
|
||||
queryFn: async () => {
|
||||
if (!api) return;
|
||||
@@ -127,13 +128,11 @@ const Settings = () => {
|
||||
enabled: open,
|
||||
});
|
||||
|
||||
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
// Server Management
|
||||
const [updating, setUpdating] = useState(false);
|
||||
const [addServerDialog, setAddServerDialog] = useState(false);
|
||||
const [serverIp, setServerIp] = useState("");
|
||||
|
||||
const handleServerChange = useMutation({
|
||||
mutationFn: async (server: RecommendedServerInfo) => {
|
||||
@@ -181,40 +180,6 @@ const Settings = () => {
|
||||
},
|
||||
});
|
||||
|
||||
const addServer = useMutation({
|
||||
mutationFn: async () => {
|
||||
const servers =
|
||||
await jellyfin.discovery.getRecommendedServerCandidates(serverIp);
|
||||
const bestServer = jellyfin.discovery.findBestServer(servers);
|
||||
return bestServer;
|
||||
},
|
||||
onSuccess: async (bestServer) => {
|
||||
if (bestServer) {
|
||||
await setServer(bestServer.systemInfo?.Id ?? "", bestServer);
|
||||
setAddServerDialog(false);
|
||||
enqueueSnackbar(
|
||||
"Client added successfully. You might need to refresh client list.",
|
||||
{
|
||||
variant: "success",
|
||||
},
|
||||
);
|
||||
await serversOnDisk.refetch();
|
||||
}
|
||||
},
|
||||
onError: (err) => {
|
||||
console.error(err);
|
||||
enqueueSnackbar(`${err}`, { variant: "error" });
|
||||
enqueueSnackbar("Something went wrong", { variant: "error" });
|
||||
},
|
||||
onSettled: async (bestServer) => {
|
||||
if (!bestServer) {
|
||||
enqueueSnackbar("Provided server address is not a Jellyfin server.", {
|
||||
variant: "error",
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// Memoize PaperProps to prevent unnecessary re-renders
|
||||
const paperProps = useMemo(
|
||||
() => ({
|
||||
@@ -636,73 +601,14 @@ const Settings = () => {
|
||||
</motion.div>
|
||||
</AnimatePresence>
|
||||
|
||||
{/* Add Server */}
|
||||
<Dialog
|
||||
<AddServerDialog
|
||||
open={addServerDialog}
|
||||
fullWidth
|
||||
setAddServerDialog={setAddServerDialog}
|
||||
hideBackdrop
|
||||
disableScrollLock={true}
|
||||
>
|
||||
<DialogTitle>Add Server</DialogTitle>
|
||||
<DialogContent className="settings-server-add">
|
||||
<TextField
|
||||
variant="filled"
|
||||
label="Address"
|
||||
fullWidth
|
||||
onChange={(e) => setServerIp(e.target.value)}
|
||||
/>
|
||||
</DialogContent>
|
||||
<DialogActions
|
||||
style={{
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
padding: "1em",
|
||||
gap: "1em",
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
variant="contained"
|
||||
startIcon={
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{
|
||||
marginRight: "0.25em",
|
||||
fontVariationSettings:
|
||||
'"FILL" 1, "wght" 300, "GRAD" 25, "opsz" 40',
|
||||
}}
|
||||
>
|
||||
cancel
|
||||
</span>
|
||||
}
|
||||
color="error"
|
||||
onClick={() => setAddServerDialog(false)}
|
||||
>
|
||||
Close
|
||||
</Button>
|
||||
{/* @ts-ignore */}
|
||||
<LoadingButton
|
||||
startIcon={
|
||||
<span
|
||||
className="material-symbols-rounded"
|
||||
style={{
|
||||
marginRight: "0.25em",
|
||||
fontVariationSettings:
|
||||
'"FILL" 1, "wght" 300, "GRAD" 25, "opsz" 40',
|
||||
}}
|
||||
>
|
||||
add_circle
|
||||
</span>
|
||||
}
|
||||
variant="contained"
|
||||
loading={addServer.isPending}
|
||||
loadingPosition="start"
|
||||
onClick={addServer.mutate}
|
||||
color="success"
|
||||
>
|
||||
Add
|
||||
</LoadingButton>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
sideEffect={async () => {
|
||||
await serversOnDisk.refetch();
|
||||
}}
|
||||
/>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -91,6 +91,7 @@ export const UserAvatarMenu = () => {
|
||||
onClose={handleMenuClose}
|
||||
sx={menuStyle}
|
||||
disableScrollLock
|
||||
PaperProps={{ className: "glass" }}
|
||||
>
|
||||
<MenuItem
|
||||
onClick={() => {
|
||||
@@ -99,7 +100,7 @@ export const UserAvatarMenu = () => {
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<div className="material-symbols-rounded">logout</div>
|
||||
<span className="material-symbols-rounded">logout</span>
|
||||
</ListItemIcon>
|
||||
Logout
|
||||
</MenuItem>
|
||||
@@ -112,7 +113,7 @@ export const UserAvatarMenu = () => {
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<div className="material-symbols-rounded">settings</div>
|
||||
<span className="material-symbols-rounded">settings</span>
|
||||
</ListItemIcon>
|
||||
Settings
|
||||
</MenuItem>
|
||||
@@ -123,7 +124,7 @@ export const UserAvatarMenu = () => {
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<div className="material-symbols-rounded">tune</div>
|
||||
<span className="material-symbols-rounded">tune</span>
|
||||
</ListItemIcon>
|
||||
Preferences
|
||||
</MenuItem>
|
||||
@@ -134,7 +135,7 @@ export const UserAvatarMenu = () => {
|
||||
}}
|
||||
>
|
||||
<ListItemIcon>
|
||||
<div className="material-symbols-rounded">info</div>
|
||||
<span className="material-symbols-rounded">info</span>
|
||||
</ListItemIcon>
|
||||
About
|
||||
</MenuItem>
|
||||
|
||||
@@ -296,10 +296,10 @@ h1 {
|
||||
}
|
||||
|
||||
.glass {
|
||||
background: rgba(0, 0, 0, 0.6) !important;
|
||||
backdrop-filter: blur(20px);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
|
||||
background-color: rgba(20, 20, 30, 0.7) !important;
|
||||
backdrop-filter: blur(24px) saturate(180%) !important;
|
||||
border: 1px solid rgba(255, 255, 255, 0.08);
|
||||
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.opacity-07{
|
||||
|
||||
Reference in new issue
Block a user