Fix routing and update deps
This commit is contained in:
5 files changed
+533
-526
No files matched your search
+4
-2
@@ -12,10 +12,12 @@
|
|||||||
"sourceType": "module"
|
"sourceType": "module"
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"react"
|
"react",
|
||||||
|
"react-refresh"
|
||||||
],
|
],
|
||||||
"rules": {
|
"rules": {
|
||||||
"no-mixed-spaces-and-tabs": "off",
|
"no-mixed-spaces-and-tabs": "off",
|
||||||
"react/prop-types": "off"
|
"react/prop-types": "off",
|
||||||
|
"react-refresh/only-export-components": "warn"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+14
-13
@@ -13,21 +13,21 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.11.1",
|
"@emotion/react": "^11.11.1",
|
||||||
"@emotion/styled": "^11.11.0",
|
"@emotion/styled": "^11.11.0",
|
||||||
"@fontsource-variable/jetbrains-mono": "^5.0.16",
|
"@fontsource-variable/jetbrains-mono": "^5.0.18",
|
||||||
"@fontsource/noto-sans": "^5.0.14",
|
"@fontsource/noto-sans": "^5.0.17",
|
||||||
"@jellyfin/sdk": "0.8.2",
|
"@jellyfin/sdk": "0.8.2",
|
||||||
"@mdi/js": "^7.2.96",
|
"@mdi/js": "^7.3.67",
|
||||||
"@mui/lab": "5.0.0-alpha.147",
|
"@mui/lab": "5.0.0-alpha.147",
|
||||||
"@mui/material": "^5.14.12",
|
"@mui/material": "^5.14.15",
|
||||||
"@tanstack/react-query": "^4.36.1",
|
"@tanstack/react-query": "^4.36.1",
|
||||||
"@tanstack/react-query-devtools": "^4.36.1",
|
"@tanstack/react-query-devtools": "^4.36.1",
|
||||||
"@tauri-apps/api": "^1.5.0",
|
"@tauri-apps/api": "^1.5.1",
|
||||||
"axios": "^1.5.1",
|
"axios": "^1.5.1",
|
||||||
"axios-tauri-api-adapter": "^0.2.0",
|
"axios-tauri-api-adapter": "^0.2.0",
|
||||||
"blurhash": "^2.0.5",
|
"blurhash": "^2.0.5",
|
||||||
"events": "^3.3.0",
|
"events": "^3.3.0",
|
||||||
"framer-motion": "^10.16.4",
|
"framer-motion": "^10.16.4",
|
||||||
"material-symbols": "^0.13.0",
|
"material-symbols": "^0.13.2",
|
||||||
"notistack": "^3.0.1",
|
"notistack": "^3.0.1",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-blurhash": "^0.3.0",
|
"react-blurhash": "^0.3.0",
|
||||||
@@ -35,23 +35,24 @@
|
|||||||
"react-error-boundary": "^4.0.11",
|
"react-error-boundary": "^4.0.11",
|
||||||
"react-multi-carousel": "^2.8.4",
|
"react-multi-carousel": "^2.8.4",
|
||||||
"react-player": "^2.13.0",
|
"react-player": "^2.13.0",
|
||||||
"react-router-dom": "^6.16.0",
|
"react-router-dom": "^6.17.0",
|
||||||
"react-use-konami": "^1.1.0",
|
"react-use-konami": "^1.1.0",
|
||||||
"tauri-plugin-log-api": "github:tauri-apps/tauri-plugin-log#v1",
|
"tauri-plugin-log-api": "github:tauri-apps/tauri-plugin-log#v1",
|
||||||
"tauri-plugin-store-api": "github:tauri-apps/tauri-plugin-store",
|
"tauri-plugin-store-api": "github:tauri-apps/tauri-plugin-store",
|
||||||
"uuid": "^9.0.1",
|
"uuid": "^9.0.1",
|
||||||
"vite-plugin-svgr": "^4.1.0",
|
"vite-plugin-svgr": "^4.1.0",
|
||||||
"wavesurfer.js": "^7.3.4",
|
"wavesurfer.js": "^7.4.2",
|
||||||
"zustand": "^4.4.3"
|
"zustand": "^4.4.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tauri-apps/cli": "^1.5.1",
|
"@tauri-apps/cli": "^1.5.6",
|
||||||
"@vitejs/plugin-react": "^4.1.0",
|
"@vitejs/plugin-react": "^4.1.0",
|
||||||
"eslint": "^8.51.0",
|
"eslint": "^8.52.0",
|
||||||
"eslint-plugin-react": "^7.33.2",
|
"eslint-plugin-react": "^7.33.2",
|
||||||
|
"eslint-plugin-react-refresh": "^0.4.3",
|
||||||
"prop-types": "^15.8.1",
|
"prop-types": "^15.8.1",
|
||||||
"sass": "^1.69.0",
|
"sass": "^1.69.5",
|
||||||
"vite": "^4.4.11",
|
"vite": "^4.5.0",
|
||||||
"vite-plugin-compression": "^0.5.1"
|
"vite-plugin-compression": "^0.5.1"
|
||||||
},
|
},
|
||||||
"license": "GPL-3.0-only"
|
"license": "GPL-3.0-only"
|
||||||
|
|||||||
Generated
+467
-417
File diff suppressed because it is too large.
Load diff
+46
-78
@@ -103,12 +103,7 @@ import { createApi, useApi } from "./utils/store/api.js";
|
|||||||
import { getSystemApi } from "@jellyfin/sdk/lib/utils/api/system-api.js";
|
import { getSystemApi } from "@jellyfin/sdk/lib/utils/api/system-api.js";
|
||||||
import { Navigate } from "react-router-dom";
|
import { Navigate } from "react-router-dom";
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
|
import { CircularProgress } from "@mui/material";
|
||||||
export const axiosClient = axios.create({
|
|
||||||
adapter: axiosTauriApiAdapter,
|
|
||||||
headers: { "Access-Control-Allow-Origin": "*" },
|
|
||||||
timeout: 60000,
|
|
||||||
});
|
|
||||||
|
|
||||||
const anim = {
|
const anim = {
|
||||||
initial: {
|
initial: {
|
||||||
@@ -125,61 +120,7 @@ const anim = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// const serverSaved = async () => {
|
|
||||||
// const defaultServer = await getDefaultServer();
|
|
||||||
// if (defaultServer) {
|
|
||||||
// return defaultServer;
|
|
||||||
// } else {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
// const usersAvailable = async () => {
|
|
||||||
// try {
|
|
||||||
// const usersList = await getUserApi(api).getPublicUsers();
|
|
||||||
// if (usersList.data.length > 0) {
|
|
||||||
// navigate("/login/users");
|
|
||||||
// } else {
|
|
||||||
// navigate("/login/manual");
|
|
||||||
// }
|
|
||||||
// } catch (error1) {
|
|
||||||
// console.error(error1);
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
// // set accessToken in api if used saved
|
|
||||||
// const createLoggedInApi = async () => {
|
|
||||||
// try {
|
|
||||||
// const defaultServer = await getDefaultServer();
|
|
||||||
// const savedServer = await getServer(defaultServer);
|
|
||||||
// const userSaved = await getUser();
|
|
||||||
// if (userSaved) {
|
|
||||||
// try {
|
|
||||||
// const authenticate = await api.authenticateUserByName(
|
|
||||||
// userSaved.Name,
|
|
||||||
// userSaved.Password,
|
|
||||||
// );
|
|
||||||
// if (authenticate.status == 200) {
|
|
||||||
// createApi(
|
|
||||||
// savedServer.address,
|
|
||||||
// authenticate.data.AccessToken,
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// } catch (error) {
|
|
||||||
// console.error(error);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } catch (error) {
|
|
||||||
// console.error(error);
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
const LogicalRoute = () => {
|
const LogicalRoute = () => {
|
||||||
const [renderCount, setRenderCount] = useState(0);
|
|
||||||
useEffect(() => {
|
|
||||||
console.log(renderCount);
|
|
||||||
setRenderCount((state) => state + 1);
|
|
||||||
}, []);
|
|
||||||
const [api] = useApi((state) => [state.api]);
|
const [api] = useApi((state) => [state.api]);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const defaultServer = useQuery({
|
const defaultServer = useQuery({
|
||||||
@@ -194,43 +135,59 @@ const LogicalRoute = () => {
|
|||||||
const result = await getServer(defaultServer.data);
|
const result = await getServer(defaultServer.data);
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
enabled: defaultServer.isSuccess && Boolean(defaultServer.data),
|
enabled: defaultServer.isSuccess,
|
||||||
});
|
});
|
||||||
const userSaved = useQuery({
|
const userSaved = useQuery({
|
||||||
queryKey: ["routing", "savedUser"],
|
queryKey: ["routing", "savedUser"],
|
||||||
queryFn: async () => await getUser(),
|
queryFn: async () => await getUser(),
|
||||||
});
|
});
|
||||||
const [accessToken, setAccessToken] = useState(null);
|
|
||||||
const authenticateUser = async () => {
|
const authenticateUser = async () => {
|
||||||
console.log("fjrii ");
|
|
||||||
const res = await api.authenticateUserByName(
|
const res = await api.authenticateUserByName(
|
||||||
userSaved.data.Name,
|
userSaved.data.Name,
|
||||||
userSaved.data.Password,
|
userSaved.data.Password,
|
||||||
);
|
);
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
if (defaultServer.isSuccess && server.isSuccess && userSaved.isSuccess) {
|
if (
|
||||||
|
!defaultServer.isLoading &&
|
||||||
|
!server.isLoading &&
|
||||||
|
!userSaved.isLoading
|
||||||
|
) {
|
||||||
if (defaultServer.data) {
|
if (defaultServer.data) {
|
||||||
if (userSaved.data.Name) {
|
if (userSaved.data) {
|
||||||
console.log(Boolean(userSaved.data));
|
|
||||||
authenticateUser();
|
authenticateUser();
|
||||||
return <Navigate replace to={"/home"} />;
|
navigate("/home");
|
||||||
|
// return <Navigate replace to={} />;
|
||||||
} else {
|
} else {
|
||||||
createApi(server.data.address);
|
createApi(server.data.address);
|
||||||
return <Navigate replace to={`/login`} />;
|
navigate("/login/index");
|
||||||
|
// return <Navigate replace to={`/login/index`} />;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return <Navigate replace to={`/setup/server`} />;
|
navigate("/setup/server");
|
||||||
|
// return <Navigate replace to={`/setup/server`} />;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return <></>;
|
return (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
position: "fixed",
|
||||||
|
top: "50%",
|
||||||
|
left: "50%",
|
||||||
|
transform: "translate(-50%, -50%)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CircularProgress size={84} thickness={1} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const LoginRoute = () => {
|
const LoginRoute = () => {
|
||||||
const [api] = useApi((state) => [state.api]);
|
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
// <Navigate replace to="/login/users" />;
|
||||||
|
const [api] = useApi((state) => [state.api]);
|
||||||
const usersList = useQuery({
|
const usersList = useQuery({
|
||||||
queryKey: ["public-users", "j"],
|
queryKey: ["public-users"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const result = await getUserApi(api).getPublicUsers();
|
const result = await getUserApi(api).getPublicUsers();
|
||||||
return result.data;
|
return result.data;
|
||||||
@@ -238,17 +195,27 @@ const LoginRoute = () => {
|
|||||||
enabled: Boolean(api),
|
enabled: Boolean(api),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (usersList.isLoading) {
|
if (usersList.isSuccess) {
|
||||||
return <h1>Loading...</h1>;
|
|
||||||
} else if (usersList.isSuccess) {
|
|
||||||
if (usersList.data.length > 0) {
|
if (usersList.data.length > 0) {
|
||||||
navigate("/login/users");
|
navigate("/login/users");
|
||||||
// return <Navigate to="/login/users" />;
|
// <Navigate replace to="/login/users" />;
|
||||||
} else {
|
} else {
|
||||||
navigate("/login/manual");
|
navigate("/login/manual");
|
||||||
// return <Navigate tp="/login/manual" />;
|
// <Navigate replace to="/login/manual" />;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
position: "fixed",
|
||||||
|
top: "50%",
|
||||||
|
left: "50%",
|
||||||
|
transform: "translate(-50%, -50%)",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CircularProgress size={84} thickness={1} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const AnimationWrapper = () => {
|
const AnimationWrapper = () => {
|
||||||
@@ -506,7 +473,8 @@ function App() {
|
|||||||
// element={<></>}
|
// element={<></>}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="/login"
|
path="/login/index"
|
||||||
|
exact
|
||||||
element={<LoginRoute />}
|
element={<LoginRoute />}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
/** @format */
|
/** @format */
|
||||||
|
|
||||||
import React, { useState, useEffect } from "react";
|
import React, { useState } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
import { EventEmitter as event } from "../../../eventEmitter.js";
|
|
||||||
import { setDefaultServer, setServer } from "../../../utils/storage/servers.js";
|
import { setDefaultServer, setServer } from "../../../utils/storage/servers.js";
|
||||||
import { getSystemApi } from "@jellyfin/sdk/lib/utils/api/system-api";
|
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
|
||||||
|
|
||||||
// MUI
|
// MUI
|
||||||
import TextField from "@mui/material/TextField";
|
import TextField from "@mui/material/TextField";
|
||||||
@@ -21,21 +18,10 @@ import { mdiChevronRight } from "@mdi/js";
|
|||||||
|
|
||||||
import { useSnackbar } from "notistack";
|
import { useSnackbar } from "notistack";
|
||||||
|
|
||||||
import {
|
|
||||||
Jellyfin,
|
|
||||||
VersionOutdatedIssue,
|
|
||||||
VersionUnsupportedIssue,
|
|
||||||
} from "@jellyfin/sdk";
|
|
||||||
import { version as appVer } from "../../../../package.json";
|
|
||||||
import { v4 as uuidv4 } from "uuid";
|
|
||||||
|
|
||||||
// SCSS
|
// SCSS
|
||||||
import "./server.module.scss";
|
import "./server.module.scss";
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
import { axiosClient } from "../../../App.jsx";
|
|
||||||
import axios from "axios";
|
|
||||||
import { useApi } from "../../../utils/store/api.js";
|
import { useApi } from "../../../utils/store/api.js";
|
||||||
import { RecommendedServerDiscovery } from "@jellyfin/sdk/lib/discovery/recommended-server-discovery.js";
|
|
||||||
import { MdiInformation } from "../../../components/icons/mdiInformation.jsx";
|
import { MdiInformation } from "../../../components/icons/mdiInformation.jsx";
|
||||||
import { yellow } from "@mui/material/colors";
|
import { yellow } from "@mui/material/colors";
|
||||||
|
|
||||||
@@ -73,7 +59,7 @@ export const ServerSetup = () => {
|
|||||||
enqueueSnackbar("Client added successfully", {
|
enqueueSnackbar("Client added successfully", {
|
||||||
variant: "success",
|
variant: "success",
|
||||||
});
|
});
|
||||||
navigate("/login");
|
navigate("/login/index");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onError: (err) => {
|
onError: (err) => {
|
||||||
|
|||||||
Reference in new issue
Block a user