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
@@ -1,4 +1,5 @@
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import type React from "react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
|
||||
import { relaunch } from "@tauri-apps/api/process";
|
||||
|
||||
@@ -19,28 +20,31 @@ import useScrollTrigger from "@mui/material/useScrollTrigger";
|
||||
import { red } from "@mui/material/colors";
|
||||
|
||||
import {
|
||||
NavLink as NavLinkBase,
|
||||
Link as RouterLink,
|
||||
type LinkProps as RouterLinkProps,
|
||||
Link,
|
||||
useLocation,
|
||||
useNavigate,
|
||||
} from "react-router-dom";
|
||||
useRouteContext,
|
||||
} from "@tanstack/react-router";
|
||||
|
||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||
import { getUserViewsApi } from "@jellyfin/sdk/lib/utils/api/user-views-api";
|
||||
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import { delServer } from "../../utils/storage/servers";
|
||||
import { delUser } from "../../utils/storage/user";
|
||||
import { useDrawerStore } from "../../utils/store/drawer";
|
||||
import { delServer } from "@/utils/storage/servers";
|
||||
import { delUser } from "@/utils/storage/user";
|
||||
import { useDrawerStore } from "@/utils/store/drawer";
|
||||
import "./appBar.scss";
|
||||
|
||||
import { EventEmitter as event } from "../../eventEmitter";
|
||||
import { useApi } from "../../utils/store/api";
|
||||
import { EventEmitter as event } from "@/eventEmitter";
|
||||
|
||||
import { getTypeIcon } from "../utils/iconsCollection";
|
||||
|
||||
import { useApiInContext } from "@/utils/store/api";
|
||||
import useSettingsStore, {
|
||||
setSettingsDialogOpen,
|
||||
setSettingsTabValue,
|
||||
} from "@/utils/store/settings";
|
||||
import {
|
||||
Divider,
|
||||
Drawer,
|
||||
@@ -49,11 +53,6 @@ import {
|
||||
ListItemButton,
|
||||
ListItemText,
|
||||
} from "@mui/material";
|
||||
import logo from "../../assets/icon.svg";
|
||||
import useSettingsStore, {
|
||||
setSettingsDialogOpen,
|
||||
setSettingsTabValue,
|
||||
} from "../../utils/store/settings";
|
||||
|
||||
interface ListItemLinkProps {
|
||||
icon?: React.ReactElement;
|
||||
@@ -61,24 +60,13 @@ interface ListItemLinkProps {
|
||||
to: string;
|
||||
}
|
||||
|
||||
const NavLink = React.forwardRef((props, ref) => (
|
||||
<NavLinkBase
|
||||
ref={ref}
|
||||
{...props}
|
||||
style={{ textDecoration: "none" }}
|
||||
className={({ isActive }) =>
|
||||
`${props.className} ${isActive ? props.activeClassName : ""}`
|
||||
}
|
||||
/>
|
||||
));
|
||||
|
||||
function ListItemLink(props: ListItemLinkProps) {
|
||||
const { icon, primary, to } = props;
|
||||
|
||||
return (
|
||||
<li>
|
||||
<ListItem
|
||||
component={NavLink}
|
||||
component={Link}
|
||||
activeClassName="active"
|
||||
className="library-drawer-item"
|
||||
to={to}
|
||||
@@ -100,7 +88,7 @@ function ListItemLink(props: ListItemLinkProps) {
|
||||
}
|
||||
|
||||
export const AppBar = () => {
|
||||
const [api] = useApi((state) => [state.api]);
|
||||
const api = useApiInContext((s) => s.api);
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [display, setDisplay] = useState(false);
|
||||
|
||||
Reference in new issue
Block a user