chore(deps): update deps
This commit is contained in:
12 files changed
+658
-576
No files matched your search
+1
-2
@@ -38,8 +38,7 @@ export const queryClient = new QueryClient({
|
||||
});
|
||||
|
||||
function ProviderWrapper() {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const createApi = useApiInContext((s) => s.createApi);
|
||||
const [api, createApi] = useApiInContext((s) => [s.api, s.createApi]);
|
||||
return <RouterProvider router={router} context={{ api, createApi }} />;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,6 @@ export const Route = createRootRouteWithContext<ApiContext>()({
|
||||
console.error(error.error);
|
||||
},
|
||||
component: () => {
|
||||
"use memo";
|
||||
const isQueryFetching = useIsFetching();
|
||||
const isMutating = useIsMutating();
|
||||
const routeIsLoading = useRouterState().isLoading;
|
||||
|
||||
+3
-18
@@ -1,18 +1,11 @@
|
||||
import {
|
||||
getAllServers,
|
||||
getDefaultServer,
|
||||
getServer,
|
||||
} from "@/utils/storage/servers";
|
||||
import { getDefaultServer, getServer } from "@/utils/storage/servers";
|
||||
import { getUser } from "@/utils/storage/user";
|
||||
import { axiosClient, useApiInContext } from "@/utils/store/api";
|
||||
import { getSystemApi } from "@jellyfin/sdk/lib/utils/api/system-api";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { Outlet, createFileRoute, redirect } from "@tanstack/react-router";
|
||||
import React from "react";
|
||||
import { Suspense } from "react";
|
||||
import { createFileRoute, redirect } from "@tanstack/react-router";
|
||||
|
||||
export const Route = createFileRoute("/_api")({
|
||||
beforeLoad: async ({ context, location }) => {
|
||||
beforeLoad: async ({ context }) => {
|
||||
console.log(context.api);
|
||||
if (!context.api) {
|
||||
const currentServerId = await getDefaultServer();
|
||||
@@ -26,14 +19,6 @@ export const Route = createFileRoute("/_api")({
|
||||
}
|
||||
}
|
||||
} else if (context.api) {
|
||||
try {
|
||||
await getSystemApi(context.api).getPingSystem(); // Verify server status
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
throw redirect({
|
||||
to: "/setup/server/error",
|
||||
});
|
||||
}
|
||||
if (context.api.accessToken) {
|
||||
try {
|
||||
await getUserApi(context.api).getCurrentUser(); // Verify user is able to authenticate
|
||||
|
||||
@@ -25,19 +25,22 @@ import { setBackdrop, useBackdropStore } from "@/utils/store/backdrop";
|
||||
|
||||
import CarouselSlide from "@/components/carouselSlide";
|
||||
import { ErrorNotice } from "@/components/notices/errorNotice/errorNotice";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { ApiContext, useApiInContext } from "@/utils/store/api";
|
||||
import { BaseItemKind, ItemFields } from "@jellyfin/sdk/lib/generated-client";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import { useSnackbar } from "notistack";
|
||||
import { ErrorBoundary } from "react-error-boundary";
|
||||
import { useStore } from "zustand";
|
||||
|
||||
export const Route = createFileRoute("/_api/home/")({
|
||||
component: Home,
|
||||
onError: (err) => {
|
||||
console.log(err);
|
||||
},
|
||||
});
|
||||
|
||||
function Home() {
|
||||
const api = useApiInContext((s) => s.api);
|
||||
|
||||
const user = useQuery({
|
||||
queryKey: ["user"],
|
||||
queryFn: async () => {
|
||||
|
||||
+6
-40
@@ -1,53 +1,19 @@
|
||||
import {
|
||||
type ServerInfo,
|
||||
getAllServers,
|
||||
getDefaultServer,
|
||||
getServer,
|
||||
} from "@/utils/storage/servers";
|
||||
import { UserStore, delUser, getUser } from "@/utils/storage/user";
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import { setAppReady, useCentralStore } from "@/utils/store/central";
|
||||
import { getSystemApi } from "@jellyfin/sdk/lib/utils/api/system-api";
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import {
|
||||
Button,
|
||||
ButtonGroup,
|
||||
CircularProgress,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import {
|
||||
Outlet,
|
||||
createFileRoute,
|
||||
redirect,
|
||||
useNavigate,
|
||||
} from "@tanstack/react-router";
|
||||
import axios from "axios";
|
||||
import { AnimatePresence, motion } from "framer-motion";
|
||||
import * as React from "react";
|
||||
import Markdown from "react-markdown";
|
||||
import remarkGfm from "remark-gfm";
|
||||
|
||||
type LoaderData = {
|
||||
serversOnDisk: ServerInfo[];
|
||||
currentServer: ServerInfo | undefined;
|
||||
userOnDisk: { Name: string; AccessToken: string } | null;
|
||||
};
|
||||
import { getDefaultServer } from "@/utils/storage/servers";
|
||||
import { getUser } from "@/utils/storage/user";
|
||||
import { createFileRoute, redirect } from "@tanstack/react-router";
|
||||
|
||||
export const Route = createFileRoute("/")({
|
||||
errorComponent: (error) => {
|
||||
console.error(error.error);
|
||||
},
|
||||
beforeLoad: async ({ context, navigate }) => {
|
||||
beforeLoad: async () => {
|
||||
const currentServerId = await getDefaultServer();
|
||||
const currentServer = await getServer(currentServerId);
|
||||
const userOnDisk = await getUser();
|
||||
if (currentServerId) {
|
||||
context.createApi(currentServer?.address, undefined);
|
||||
if (userOnDisk) {
|
||||
context.createApi(currentServer?.address, userOnDisk.AccessToken);
|
||||
throw redirect({ to: "/home/" });
|
||||
throw redirect({ to: "/home" });
|
||||
}
|
||||
throw redirect({ to: "/login/" });
|
||||
throw redirect({ to: "/login" });
|
||||
}
|
||||
|
||||
throw redirect({ to: "/setup/server/add" });
|
||||
|
||||
@@ -11,7 +11,7 @@ import Typography from "@mui/material/Typography";
|
||||
|
||||
import { useSnackbar } from "notistack";
|
||||
|
||||
import { createApi, jellyfin } from "@/utils/store/api";
|
||||
import { jellyfin, useApiInContext } from "@/utils/store/api";
|
||||
import { yellow } from "@mui/material/colors";
|
||||
import { useMutation } from "@tanstack/react-query";
|
||||
// SCSS
|
||||
@@ -24,6 +24,7 @@ export const Route = createFileRoute("/setup/server/add")({
|
||||
|
||||
function ServerSetup() {
|
||||
const [serverIp, setServerIp] = useState("");
|
||||
const createApi = useApiInContext((s) => s.createApi);
|
||||
|
||||
const { enqueueSnackbar } = useSnackbar();
|
||||
|
||||
@@ -47,7 +48,7 @@ function ServerSetup() {
|
||||
variant: "success",
|
||||
});
|
||||
|
||||
navigate({ to: "/login/index" });
|
||||
navigate({ to: "/login" });
|
||||
}
|
||||
},
|
||||
onError: (err) => {
|
||||
|
||||
+13
-5
@@ -52,7 +52,7 @@ export const jellyfin = new Jellyfin({
|
||||
// jellyfin: jellyfin,
|
||||
// }));
|
||||
|
||||
const ApiContext = createContext(null);
|
||||
export const ApiContext = createContext(null);
|
||||
|
||||
export const ApiProvider = ({ children }) => {
|
||||
const [store] = useState(() =>
|
||||
@@ -61,10 +61,18 @@ export const ApiProvider = ({ children }) => {
|
||||
deviceId: deviceId,
|
||||
jellyfin: jellyfin,
|
||||
createApi: (serverAddress, accessToken?) =>
|
||||
set((state) => ({
|
||||
...state,
|
||||
api: jellyfin.createApi(serverAddress, accessToken, axiosClient),
|
||||
})),
|
||||
set((state) => {
|
||||
const apiTemp = state.jellyfin.createApi(
|
||||
serverAddress,
|
||||
accessToken,
|
||||
axiosClient,
|
||||
);
|
||||
console.info(apiTemp);
|
||||
return {
|
||||
...state,
|
||||
api: apiTemp,
|
||||
};
|
||||
}),
|
||||
})),
|
||||
)
|
||||
return <ApiContext.Provider value={store}>{children}</ApiContext.Provider>;
|
||||
|
||||
Reference in new issue
Block a user