refactor: move to tanstack router
This commit is contained in:
1 parent
a4ea932153
commit
522621ed69
136 files changed
+7063
-6127
No files matched your search
+114
-290
@@ -1,3 +1,7 @@
|
||||
import useSettingsStore, {
|
||||
setSettingsDialogOpen,
|
||||
setSettingsTabValue,
|
||||
} from "@/utils/store/settings";
|
||||
import {
|
||||
Button,
|
||||
Chip,
|
||||
@@ -21,34 +25,30 @@ import {
|
||||
} from "@mui/material";
|
||||
import { AnimatePresence, motion, transform } from "framer-motion";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import useSettingsStore, {
|
||||
setSettingsDialogOpen,
|
||||
setSettingsTabValue,
|
||||
} from "../../utils/store/settings";
|
||||
|
||||
import logo from "../../assets/logoBlack.png";
|
||||
import logo from "@/assets/logo.png";
|
||||
|
||||
import { createApi, jellyfin, useApiInContext } from "@/utils/store/api";
|
||||
import { useCentralStore } from "@/utils/store/central";
|
||||
import { getSystemApi } from "@jellyfin/sdk/lib/utils/api/system-api";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { createApi, useApi } from "../../utils/store/api";
|
||||
import { useCentralStore } from "../../utils/store/central";
|
||||
import "./settings.scss";
|
||||
|
||||
import type { RecommendedServerInfo } from "@jellyfin/sdk";
|
||||
import { LoadingButton } from "@mui/lab";
|
||||
import { red, yellow } from "@mui/material/colors";
|
||||
import { relaunch } from "@tauri-apps/api/process";
|
||||
import { checkUpdate, installUpdate } from "@tauri-apps/api/updater";
|
||||
import { enqueueSnackbar, useSnackbar } from "notistack";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import {
|
||||
delServer,
|
||||
getAllServers,
|
||||
getDefaultServer,
|
||||
setDefaultServer,
|
||||
setServer,
|
||||
} from "../../utils/storage/servers";
|
||||
import { delUser } from "../../utils/storage/user";
|
||||
} from "@/utils/storage/servers";
|
||||
import { delUser } from "@/utils/storage/user";
|
||||
import type { RecommendedServerInfo } from "@jellyfin/sdk";
|
||||
import { LoadingButton } from "@mui/lab";
|
||||
import { red, yellow } from "@mui/material/colors";
|
||||
import { useNavigate, useRouteContext } from "@tanstack/react-router";
|
||||
import { relaunch } from "@tauri-apps/api/process";
|
||||
import { checkUpdate, installUpdate } from "@tauri-apps/api/updater";
|
||||
import { enqueueSnackbar, useSnackbar } from "notistack";
|
||||
|
||||
const motionConfig = {
|
||||
initial: {
|
||||
@@ -64,7 +64,8 @@ const Settings = () => {
|
||||
state.dialogOpen,
|
||||
state.tabValue,
|
||||
]);
|
||||
const [api, jellyfin] = useApi((state) => [state.api, state.jellyfin]);
|
||||
const api = useApiInContext((s) => s.api);
|
||||
|
||||
const systemInfo = useQuery({
|
||||
queryKey: ["about", "systemInfo"],
|
||||
queryFn: async () => {
|
||||
@@ -116,7 +117,7 @@ const Settings = () => {
|
||||
},
|
||||
onSuccess: async () => {
|
||||
setSettingsDialogOpen(false);
|
||||
navigate("/login/index");
|
||||
navigate({ to: "/login/index" });
|
||||
},
|
||||
onError: (error) => {
|
||||
console.error(error);
|
||||
@@ -139,12 +140,12 @@ const Settings = () => {
|
||||
setDefaultServer(serversOnDisk.data[0].id);
|
||||
createApi(serversOnDisk.data[0].address, null);
|
||||
} else {
|
||||
// Reset Api as no server is present on disk
|
||||
useApi.setState(useApi.getInitialState());
|
||||
// TODO: Reset api in context
|
||||
// useApi.setState(useApi.getInitialState());
|
||||
}
|
||||
setSettingsDialogOpen(false);
|
||||
await queryClient.removeQueries();
|
||||
navigate("/");
|
||||
navigate({ to: "/" });
|
||||
}
|
||||
enqueueSnackbar("Server deleted successfully!", { variant: "success" });
|
||||
await serversOnDisk.refetch();
|
||||
@@ -193,7 +194,9 @@ const Settings = () => {
|
||||
maxWidth="md"
|
||||
PaperProps={{
|
||||
className: "settings glass",
|
||||
elevation: 10,
|
||||
}}
|
||||
hideBackdrop
|
||||
onClose={() => setSettingsDialogOpen(false)}
|
||||
>
|
||||
<Tabs
|
||||
@@ -256,246 +259,28 @@ const Settings = () => {
|
||||
{/* General */}
|
||||
{tabValue === 1 && (
|
||||
<div className="settings-container">
|
||||
<FormControlLabel
|
||||
value="start"
|
||||
control={<Switch color="primary" />}
|
||||
label={
|
||||
<div className="settings-option-info">
|
||||
<Typography variant="h6" fontWeight={400}>
|
||||
Enable DiscordRPC
|
||||
</Typography>
|
||||
<Typography variant="subtitle2" fontWeight={200}>
|
||||
this a test
|
||||
</Typography>
|
||||
</div>
|
||||
}
|
||||
labelPlacement="start"
|
||||
className="settings-option"
|
||||
/>
|
||||
<FormControlLabel
|
||||
value="start"
|
||||
control={<Switch color="primary" />}
|
||||
label={
|
||||
<div className="settings-option-info">
|
||||
<Typography variant="h6" fontWeight={400}>
|
||||
Enable DiscordRPC
|
||||
</Typography>
|
||||
<Typography variant="subtitle2" fontWeight={200}>
|
||||
this a test
|
||||
</Typography>
|
||||
</div>
|
||||
}
|
||||
labelPlacement="start"
|
||||
className="settings-option"
|
||||
/>
|
||||
<FormControlLabel
|
||||
value="start"
|
||||
control={<Switch color="primary" />}
|
||||
label={
|
||||
<div className="settings-option-info">
|
||||
<Typography variant="h6" fontWeight={400}>
|
||||
Enable DiscordRPC
|
||||
</Typography>
|
||||
<Typography variant="subtitle2" fontWeight={200}>
|
||||
this a test
|
||||
</Typography>
|
||||
</div>
|
||||
}
|
||||
labelPlacement="start"
|
||||
className="settings-option"
|
||||
/>
|
||||
<FormControlLabel
|
||||
value="start"
|
||||
control={<Switch color="primary" />}
|
||||
label={
|
||||
<div className="settings-option-info">
|
||||
<Typography variant="h6" fontWeight={400}>
|
||||
Enable DiscordRPC
|
||||
</Typography>
|
||||
<Typography variant="subtitle2" fontWeight={200}>
|
||||
this a test
|
||||
</Typography>
|
||||
</div>
|
||||
}
|
||||
labelPlacement="start"
|
||||
className="settings-option"
|
||||
/>
|
||||
<FormControlLabel
|
||||
value="start"
|
||||
control={<Switch color="primary" />}
|
||||
label={
|
||||
<div className="settings-option-info">
|
||||
<Typography variant="h6" fontWeight={400}>
|
||||
Enable DiscordRPC
|
||||
</Typography>
|
||||
<Typography variant="subtitle2" fontWeight={200}>
|
||||
this a test
|
||||
</Typography>
|
||||
</div>
|
||||
}
|
||||
labelPlacement="start"
|
||||
className="settings-option"
|
||||
/>
|
||||
<FormControlLabel
|
||||
value="start"
|
||||
control={<Switch color="primary" />}
|
||||
label={
|
||||
<div className="settings-option-info">
|
||||
<Typography variant="h6" fontWeight={400}>
|
||||
Enable DiscordRPC
|
||||
</Typography>
|
||||
<Typography variant="subtitle2" fontWeight={200}>
|
||||
this a test
|
||||
</Typography>
|
||||
</div>
|
||||
}
|
||||
labelPlacement="start"
|
||||
className="settings-option"
|
||||
/>
|
||||
<FormControlLabel
|
||||
value="start"
|
||||
control={<Switch color="primary" />}
|
||||
label={
|
||||
<div className="settings-option-info">
|
||||
<Typography variant="h6" fontWeight={400}>
|
||||
Enable DiscordRPC
|
||||
</Typography>
|
||||
<Typography variant="subtitle2" fontWeight={200}>
|
||||
this a test
|
||||
</Typography>
|
||||
</div>
|
||||
}
|
||||
labelPlacement="start"
|
||||
className="settings-option"
|
||||
/>
|
||||
<FormControlLabel
|
||||
value="start"
|
||||
control={<Switch color="primary" />}
|
||||
label={
|
||||
<div className="settings-option-info">
|
||||
<Typography variant="h6" fontWeight={400}>
|
||||
Enable DiscordRPC
|
||||
</Typography>
|
||||
<Typography variant="subtitle2" fontWeight={200}>
|
||||
this a test
|
||||
</Typography>
|
||||
</div>
|
||||
}
|
||||
labelPlacement="start"
|
||||
className="settings-option"
|
||||
/>
|
||||
<FormControlLabel
|
||||
value="start"
|
||||
control={<Switch color="primary" />}
|
||||
label={
|
||||
<div className="settings-option-info">
|
||||
<Typography variant="h6" fontWeight={400}>
|
||||
Enable DiscordRPC
|
||||
</Typography>
|
||||
<Typography variant="subtitle2" fontWeight={200}>
|
||||
this a test
|
||||
</Typography>
|
||||
</div>
|
||||
}
|
||||
labelPlacement="start"
|
||||
className="settings-option"
|
||||
/>
|
||||
<FormControlLabel
|
||||
value="start"
|
||||
control={<Switch color="primary" />}
|
||||
label={
|
||||
<div className="settings-option-info">
|
||||
<Typography variant="h6" fontWeight={400}>
|
||||
Enable DiscordRPC
|
||||
</Typography>
|
||||
<Typography variant="subtitle2" fontWeight={200}>
|
||||
this a test
|
||||
</Typography>
|
||||
</div>
|
||||
}
|
||||
labelPlacement="start"
|
||||
className="settings-option"
|
||||
/>
|
||||
<FormControlLabel
|
||||
value="start"
|
||||
control={<Switch color="primary" />}
|
||||
label={
|
||||
<div className="settings-option-info">
|
||||
<Typography variant="h6" fontWeight={400}>
|
||||
Enable DiscordRPC
|
||||
</Typography>
|
||||
<Typography variant="subtitle2" fontWeight={200}>
|
||||
this a test
|
||||
</Typography>
|
||||
</div>
|
||||
}
|
||||
labelPlacement="start"
|
||||
className="settings-option"
|
||||
/>
|
||||
<FormControlLabel
|
||||
value="start"
|
||||
control={<Switch color="primary" />}
|
||||
label={
|
||||
<div className="settings-option-info">
|
||||
<Typography variant="h6" fontWeight={400}>
|
||||
Enable DiscordRPC
|
||||
</Typography>
|
||||
<Typography variant="subtitle2" fontWeight={200}>
|
||||
this a test
|
||||
</Typography>
|
||||
</div>
|
||||
}
|
||||
labelPlacement="start"
|
||||
className="settings-option"
|
||||
/>
|
||||
<FormControlLabel
|
||||
value="start"
|
||||
control={<Switch color="primary" />}
|
||||
label={
|
||||
<div className="settings-option-info">
|
||||
<Typography variant="h6" fontWeight={400}>
|
||||
Enable DiscordRPC
|
||||
</Typography>
|
||||
<Typography variant="subtitle2" fontWeight={200}>
|
||||
this a test
|
||||
</Typography>
|
||||
</div>
|
||||
}
|
||||
labelPlacement="start"
|
||||
className="settings-option"
|
||||
/>
|
||||
<FormControlLabel
|
||||
value="start"
|
||||
control={<Switch color="primary" />}
|
||||
label={
|
||||
<div className="settings-option-info">
|
||||
<Typography variant="h6" fontWeight={400}>
|
||||
Enable DiscordRPC
|
||||
</Typography>
|
||||
<Typography variant="subtitle2" fontWeight={200}>
|
||||
this a test
|
||||
</Typography>
|
||||
</div>
|
||||
}
|
||||
labelPlacement="start"
|
||||
className="settings-option"
|
||||
/>
|
||||
<FormControlLabel
|
||||
value="start"
|
||||
control={<Switch color="primary" />}
|
||||
label={
|
||||
<div className="settings-option-info">
|
||||
<Typography variant="h6" fontWeight={400}>
|
||||
Enable DiscordRPC
|
||||
</Typography>
|
||||
<Typography variant="subtitle2" fontWeight={200}>
|
||||
this a test
|
||||
</Typography>
|
||||
</div>
|
||||
}
|
||||
labelPlacement="start"
|
||||
className="settings-option"
|
||||
/>
|
||||
{Array.from(new Array(10)).map((i) => (
|
||||
<FormControlLabel
|
||||
key={i}
|
||||
value="start"
|
||||
control={<Switch color="primary" />}
|
||||
label={
|
||||
<div className="settings-option-info">
|
||||
<Typography variant="subtitle1">
|
||||
Some dummy setting
|
||||
</Typography>
|
||||
<Typography
|
||||
variant="caption"
|
||||
className="settings-option-info-caption"
|
||||
>
|
||||
this a test
|
||||
</Typography>
|
||||
</div>
|
||||
}
|
||||
labelPlacement="start"
|
||||
className="settings-option"
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -516,7 +301,7 @@ const Settings = () => {
|
||||
opacity: 0,
|
||||
}}
|
||||
animate={{ transform: "translateY(0px)", opacity: 1 }}
|
||||
exit={{ transform: "translateY(-10px)", opacity: 1 }}
|
||||
exit={{ transform: "translateY(-10px)", opacity: 0 }}
|
||||
transition={{
|
||||
delay: 0.1 * index,
|
||||
duration: 0.15,
|
||||
@@ -644,7 +429,7 @@ const Settings = () => {
|
||||
<div className="settings-grid">
|
||||
<div className="settings-info-container">
|
||||
<div className="settings-info">
|
||||
<Typography>Client Version:</Typography>
|
||||
<Typography variant="subtitle2">Client Version:</Typography>
|
||||
<Chip
|
||||
icon={
|
||||
<span className="material-symbols-rounded">
|
||||
@@ -654,27 +439,45 @@ const Settings = () => {
|
||||
</span>
|
||||
}
|
||||
label={
|
||||
<Typography variant="subtitle1">
|
||||
<Typography variant="subtitle2">
|
||||
{applicationVersion}
|
||||
</Typography>
|
||||
}
|
||||
color={
|
||||
updateInfo.data?.shouldUpdate ? "error" : "success"
|
||||
}
|
||||
size="medium"
|
||||
color={updateInfo.data?.shouldUpdate ? "error" : "info"}
|
||||
size="small"
|
||||
style={{
|
||||
width: "fit-content !important",
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className="settings-info">
|
||||
<Typography>Update Available:</Typography>
|
||||
<Typography>
|
||||
{updateInfo.isFetching
|
||||
? "Checking for new updates..."
|
||||
: updateInfo.data?.shouldUpdate
|
||||
? updateInfo.data.manifest?.version
|
||||
: "No update found."}
|
||||
<Typography variant="subtitle2">
|
||||
Update Available:
|
||||
</Typography>
|
||||
<Typography variant="subtitle2">
|
||||
{updateInfo.isFetching ? (
|
||||
"Checking for new updates..."
|
||||
) : updateInfo.data?.shouldUpdate ? (
|
||||
<Chip
|
||||
icon={
|
||||
<span className="material-symbols-rounded">
|
||||
update
|
||||
</span>
|
||||
}
|
||||
label={
|
||||
<Typography variant="subtitle2">
|
||||
{applicationVersion}
|
||||
</Typography>
|
||||
}
|
||||
color="success"
|
||||
size="small"
|
||||
style={{
|
||||
width: "fit-content !important",
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
"No update found."
|
||||
)}
|
||||
</Typography>
|
||||
</div>
|
||||
<LoadingButton
|
||||
@@ -709,22 +512,32 @@ const Settings = () => {
|
||||
{systemInfo.isSuccess ? (
|
||||
<div className="settings-info-container">
|
||||
<div className="settings-info">
|
||||
<Typography>Server:</Typography>
|
||||
<Typography>{systemInfo.data?.ServerName}</Typography>
|
||||
<Typography variant="subtitle2">Server:</Typography>
|
||||
<Typography variant="subtitle2">
|
||||
{systemInfo.data?.ServerName}
|
||||
</Typography>
|
||||
</div>
|
||||
<div className="settings-info">
|
||||
<Typography>Jellyfin Version:</Typography>
|
||||
<Typography>{systemInfo.data?.Version}</Typography>
|
||||
<Typography variant="subtitle2">
|
||||
Jellyfin Version:
|
||||
</Typography>
|
||||
<Typography variant="subtitle2">
|
||||
{systemInfo.data?.Version}
|
||||
</Typography>
|
||||
</div>
|
||||
<div className="settings-info">
|
||||
<Typography>Operating System:</Typography>
|
||||
<Typography>
|
||||
<Typography variant="subtitle2">
|
||||
Operating System:
|
||||
</Typography>
|
||||
<Typography variant="subtitle2">
|
||||
{systemInfo.data?.OperatingSystemDisplayName}
|
||||
</Typography>
|
||||
</div>
|
||||
<div className="settings-info">
|
||||
<Typography>Server Architecture:</Typography>
|
||||
<Typography>
|
||||
<Typography variant="subtitle2">
|
||||
Server Architecture:
|
||||
</Typography>
|
||||
<Typography variant="subtitle2">
|
||||
{systemInfo.data?.SystemArchitecture}
|
||||
</Typography>
|
||||
</div>
|
||||
@@ -745,10 +558,9 @@ const Settings = () => {
|
||||
background: "rgb(0 0 0 / 0.3)",
|
||||
padding: "1em",
|
||||
borderRadius: "10px",
|
||||
border: "1px solid rgb(255 255 255 / 0.1)",
|
||||
}}
|
||||
>
|
||||
<Typography variant="h6" fontWeight={300} mb={1}>
|
||||
<Typography variant="subtitle1" mb={1}>
|
||||
Links:
|
||||
</Typography>
|
||||
<div
|
||||
@@ -759,15 +571,22 @@ const Settings = () => {
|
||||
gap: "0.1em",
|
||||
}}
|
||||
>
|
||||
<Link
|
||||
<Typography
|
||||
component={Link}
|
||||
variant="subtitle2"
|
||||
target="_blank"
|
||||
href="https://github.com/prayag17/JellyPlayer"
|
||||
>
|
||||
https://github.com/prayag17/JellyPlayer
|
||||
</Link>
|
||||
<Link target="_blank" href="https://jellyfin.org">
|
||||
</Typography>
|
||||
<Typography
|
||||
component={Link}
|
||||
variant="subtitle2"
|
||||
target="_blank"
|
||||
href="https://jellyfin.org"
|
||||
>
|
||||
https://jellyfin.org
|
||||
</Link>
|
||||
</Typography>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -776,7 +595,12 @@ const Settings = () => {
|
||||
</AnimatePresence>
|
||||
|
||||
{/* Add Server */}
|
||||
<Dialog open={addServerDialog} fullWidth>
|
||||
<Dialog
|
||||
open={addServerDialog}
|
||||
fullWidth
|
||||
hideBackdrop
|
||||
disableScrollLock={true}
|
||||
>
|
||||
<DialogTitle>Add Server</DialogTitle>
|
||||
<DialogContent className="settings-server-add">
|
||||
<TextField
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
grid-template-columns: 20% 1fr;
|
||||
height: 60vh;
|
||||
overflow: hidden !important;
|
||||
|
||||
.MuiTabs-flexContainerVertical{
|
||||
height: 100%;
|
||||
}
|
||||
@@ -23,8 +22,8 @@
|
||||
}
|
||||
&-scroll{
|
||||
overflow-y: auto;
|
||||
mask-image: linear-gradient(to top, transparent, black 15px calc(100% - 15px), transparent);
|
||||
scrollbar-gutter:stable ;
|
||||
overscroll-behavior: contain;
|
||||
// Magic scrollbar
|
||||
&::-webkit-scrollbar {
|
||||
&-thumb {
|
||||
@@ -48,9 +47,11 @@
|
||||
&-logo{
|
||||
width: 100%;
|
||||
background: rgb(255 255 255 / 1);
|
||||
padding: 2em;
|
||||
padding: 0em;
|
||||
height: 10em;
|
||||
margin-bottom: 1em;
|
||||
border-radius: $border-radius-default;
|
||||
object-fit: contain;
|
||||
}
|
||||
&-info{
|
||||
display: grid;
|
||||
@@ -58,17 +59,24 @@
|
||||
gap: 1em;
|
||||
justify-items: start;
|
||||
align-items: center;
|
||||
|
||||
border-bottom: 1px solid rgb(255 255 255 / 0.1);
|
||||
padding-bottom: 0.5em;
|
||||
&-container{
|
||||
background: rgb(0 0 0 / 0.3);
|
||||
border: 1px solid rgb(255 255 255 / 0.1);
|
||||
padding: 1em;
|
||||
border-radius: $border-radius-default;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap:0.4em;
|
||||
gap:0.6em;
|
||||
width: 100%;
|
||||
}
|
||||
&:last-child {
|
||||
border: none;
|
||||
padding-bottom: 0em;
|
||||
}
|
||||
> :last-child {
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
|
||||
//settings
|
||||
@@ -78,7 +86,11 @@
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
padding: 0 !important;
|
||||
margin: 0 0 0.4em 0!important;
|
||||
margin: 0 !important;
|
||||
margin-bottom: 0.6em !important;
|
||||
&-info-caption{
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
|
||||
//serverList
|
||||
|
||||
Reference in new issue
Block a user