refactor: move most routing logic to tanstack

This commit is contained in:
Prayag Prajapati committed 2024-05-29 18:10:22 +05:30
1 parent b8552ac35d
commit c22dbefeea
22 files changed
+1191 -1502

No files matched your search

+1
View File
@@ -0,0 +1 @@
{"encodings":["src\\main.tsx","ProviderWrapper",[40,0,44,1],[41,13,41,42],[42,19,42,54],[43,8,43,71],"src\\utils\\store\\api.tsx","ApiProvider",[57,27,71,1],[57,28,57,40],[58,17,69,2],[70,8,70,75],"useApiInContext",[73,7,79,1],[74,15,74,37],[78,8,78,34],"src\\routes\\_api\\search\\index.jsx","SearchPage",[30,0,448,1],[31,13,31,36],[33,37,33,49],[34,21,34,49],[36,14,44,3],[48,16,62,3],[63,16,77,3],[78,20,92,3],[93,15,107,3],[108,14,122,3],[123,22,137,3],[138,16,150,3],[151,18,164,3],[166,23,166,71],[168,1,171,7],[173,2,446,8],[183,3,236,9],[184,4,235,6],[201,7,230,24],[202,8,229,14],[210,9,227,11],[228,9,228,65],[237,3,421,9],[243,5,262,20],[245,7,260,9],[265,5,290,20],[267,7,288,9],[293,5,307,20],[296,8,304,10],[310,5,329,20],[312,7,327,9],[332,5,352,20],[334,7,350,9],[355,5,375,20],[357,7,373,9],[378,5,397,20],[380,7,395,9],[400,5,419,20],[402,7,417,9],[438,5,444,11],[443,6,443,68],"src\\routes\\_api\\favorite\\index.tsx","FavoritePage",[20,0,304,1],[21,13,21,36],[22,23,22,71],[24,14,32,3],[34,16,45,3],[47,16,58,3],[60,20,71,3],[73,15,84,3],[86,14,97,3],[99,22,110,3],[112,16,123,3],[125,1,127,3],[130,2,302,9],[141,4,160,19],[143,6,158,8],[163,4,188,19],[165,6,186,8],[191,4,210,19],[193,6,208,8],[213,4,233,19],[215,6,231,8],[236,4,256,19],[238,6,254,8],[259,4,278,19],[261,6,276,8],[281,4,300,19],[283,6,298,8],"src\\routes\\_api\\home\\index.tsx","Home",[38,0,419,1],[39,13,39,42],[41,14,49,3],[51,19,61,3],[63,21,83,3],[85,26,99,3],[101,26,114,3],[116,21,135,3],[137,47,137,59],[139,18,139,31],[145,1,162,26],[162,5,162,24],[171,3,416,10],[178,4,205,20],[180,6,180,26],[183,7,202,9],[185,9,185,52],[207,4,241,20],[209,6,211,12],[210,7,210,51],[215,6,215,23],[217,6,239,21],[221,10,236,12],[242,4,303,20],[244,6,246,12],[245,7,245,52],[250,6,250,23],[254,6,301,21],[257,9,298,11],[304,4,362,20],[306,6,308,12],[307,7,307,59],[312,6,312,23],[317,6,360,21],[320,9,357,11],[363,4,404,20],[365,6,367,12],[366,7,366,59],[371,6,371,23],[376,6,402,21],[379,9,399,11],[405,4,415,20],[407,6,409,12],[408,7,408,62],[413,13,413,69],"src\\routes\\setup\\server.add.tsx","ServerSetup",[25,0,152,1],[26,33,26,45],[28,29,28,42],[30,18,30,60],[32,21,66,3],[70,3,79,5],[80,3,149,15],[88,4,148,11],[95,5,97,12],[96,6,96,54],[98,5,108,12],[99,6,107,8],[109,5,123,12],[110,6,122,22],[116,8,116,71],[124,5,147,12],[136,6,143,13],[144,6,146,19],"src\\routes\\_api\\player\\index.tsx","VideoPlayer",[81,0,592,1],[82,13,82,36],[83,21,83,32],[84,39,84,54],[96,5,106,3],[108,31,108,45],[109,41,109,55],[111,51,111,66],[114,31,114,46],[115,31,115,45],[116,35,116,50],[117,45,117,68],[118,33,118,56],[119,43,119,58],[120,43,120,67],[121,49,123,2],[124,29,124,40],[125,27,125,42],[127,1,127,41],[129,49,129,71],[209,16,209,28],[223,24,259,7],[261,1,269,21],[269,5,269,19],[271,1,302,38],[302,5,302,18],[302,20,302,36],[304,1,307,15],[307,5,307,13],[310,2,590,8],[311,3,334,21],[313,5,332,18],[331,6,331,52],[335,3,562,16],[352,4,400,10],[353,5,355,18],[354,6,354,66],[356,5,360,18],[359,6,359,64],[361,5,399,12],[382,6,398,18],[390,7,392,18],[394,8,396,19],[401,4,561,10],[402,5,409,18],[405,7,407,20],[410,5,560,11],[411,6,452,12],[412,7,445,9],[446,7,451,13],[447,8,449,21],[450,8,450,61],[453,6,559,12],[454,7,485,13],[455,8,455,30],[456,8,464,21],[461,9,463,16],[465,8,469,21],[466,9,468,16],[470,8,478,21],[475,9,477,16],[479,8,479,26],[480,8,484,21],[486,7,558,13],[487,8,523,21],[509,9,511,22],[512,9,522,11],[524,8,537,21],[530,9,536,16],[538,8,538,23],[539,8,545,21],[540,9,544,16],[546,8,557,21],[554,9,556,16],[564,3,589,5],"src\\routes\\_api\\login\\index.tsx","LoginRoute",[19,0,91,1],[20,18,20,31],[21,18,21,31],[22,13,22,36],[23,29,23,65],[25,19,32,3],[48,2,89,13],[48,22,48,45],[49,3,88,9],[60,4,60,48],[61,4,87,22],[62,5,86,18],[75,6,85,19],"src\\routes\\setup\\server.list.tsx","ServerList",[28,0,203,1],[29,18,29,31],[30,39,30,53],[31,29,31,42],[33,21,33,37],[35,17,38,3],[40,23,43,3],[45,28,63,3],[87,1,89,7],[92,2,201,8],[93,3,93,21],[94,3,114,9],[103,4,105,17],[106,4,113,17],[112,5,112,56],[115,3,200,11],[118,6,198,12],[119,7,121,13],[122,7,170,13],[123,8,151,21],[133,10,149,12],[135,12,141,25],[152,8,160,21],[161,8,169,21],[171,7,197,13],[172,8,183,21],[182,9,182,62],[184,8,196,21],[195,9,195,71],"src\\routes\\_api\\playlist\\$id.jsx","TabPanel",[23,0,38,1],[23,18,23,23],[27,2,36,8],[35,23,35,44],"PlaylistTitlePage",[57,0,229,1],[58,16,58,33],[59,13,59,36],[61,14,69,3],[71,14,84,3],[86,22,99,3],[101,21,112,3],[114,26,114,74],[116,1,126,7],[130,3,140,9],[139,4,139,24],[145,3,223,9],[160,7,168,9],[174,5,221,20],[181,8,218,10],[227,9,227,24],"src\\routes\\_api\\series\\$id.tsx",[65,0,80,1],[65,18,65,23],[69,2,78,8],[77,23,77,44],"SeriesTitlePage",[99,0,1205,1],[100,16,100,33],[102,13,102,36],[104,14,112,3],[114,14,127,3],[129,22,142,3],[144,17,157,3],[159,23,174,3],[176,43,179,3],[180,55,180,70],[182,43,185,3],[187,27,199,3],[201,18,216,3],[218,25,228,3],[229,26,229,74],[231,35,231,47],[232,31,232,43],[233,29,233,41],[234,35,234,47],[236,1,260,21],[260,5,260,19],[262Line truncated
+19 -18
View File
@@ -19,30 +19,31 @@
"@fontsource-variable/noto-sans": "^5.0.5", "@fontsource-variable/noto-sans": "^5.0.5",
"@fontsource/noto-sans": "^5.0.22", "@fontsource/noto-sans": "^5.0.22",
"@jellyfin/sdk": "0.9.0", "@jellyfin/sdk": "0.9.0",
"@million/lint": "^0.0.73", "@million/lint": "1.0.0-rc.13",
"@mui/lab": "5.0.0-alpha.170", "@mui/lab": "5.0.0-alpha.170",
"@mui/material": "6.0.0-alpha.6", "@mui/material": "6.0.0-alpha.6",
"@tanem/react-nprogress": "^5.0.51", "@tanem/react-nprogress": "^5.0.51",
"@tanstack/react-query": "^5.36.0", "@tanstack/react-query": "^5.40.0",
"@tanstack/react-query-devtools": "^5.36.0", "@tanstack/react-query-devtools": "^5.40.0",
"@tanstack/react-router": "^1.32.5", "@tanstack/react-router": "^1.34.5",
"@tanstack/react-virtual": "^3.5.0", "@tanstack/react-virtual": "^3.5.0",
"@tauri-apps/api": "^1.5.5", "@tauri-apps/api": "^1.5.6",
"@types/node": "^20.12.12", "@types/node": "^20.12.12",
"@types/react": "^18.3.2", "@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0", "@types/react-dom": "^18.3.0",
"axios": "^1.6.8", "axios": "^1.7.2",
"axios-tauri-api-adapter": "^0.2.1", "axios-tauri-api-adapter": "^0.2.1",
"babel-plugin-react-compiler": "0.0.0-experimental-592953e-20240517",
"blurhash": "^2.0.5", "blurhash": "^2.0.5",
"events": "^3.3.0", "events": "^3.3.0",
"framer-motion": "^11.2.0", "framer-motion": "^11.2.7",
"jassub": "^1.7.15", "jassub": "^1.7.15",
"material-symbols": "^0.18.0", "material-symbols": "^0.18.0",
"million": "^3.0.6", "million": "^3.1.6",
"notistack": "^3.0.1", "notistack": "^3.0.1",
"react": "^18.3.1", "react": "18.3.1",
"react-blurhash": "^0.3.0", "react-blurhash": "^0.3.0",
"react-dom": "^18.3.1", "react-dom": "18.3.1",
"react-error-boundary": "^4.0.13", "react-error-boundary": "^4.0.13",
"react-markdown": "^9.0.1", "react-markdown": "^9.0.1",
"react-multi-carousel": "^2.8.5", "react-multi-carousel": "^2.8.5",
@@ -53,19 +54,19 @@
"tauri-plugin-store-api": "github:tauri-apps/tauri-plugin-store", "tauri-plugin-store-api": "github:tauri-apps/tauri-plugin-store",
"typescript": "^5.4.5", "typescript": "^5.4.5",
"vite-plugin-svgr": "^4.2.0", "vite-plugin-svgr": "^4.2.0",
"wavesurfer.js": "^7.7.14", "wavesurfer.js": "^7.7.15",
"zustand": "^4.5.2" "zustand": "^4.5.2"
}, },
"devDependencies": { "devDependencies": {
"@biomejs/biome": "^1.7.3", "@biomejs/biome": "^1.7.3",
"@tanstack/router-cli": "^1.32.2", "@tanstack/router-cli": "^1.33.12",
"@tanstack/router-devtools": "^1.32.5", "@tanstack/router-devtools": "^1.34.5",
"@tanstack/router-vite-plugin": "^1.32.2", "@tanstack/router-vite-plugin": "^1.34.1",
"@tauri-apps/cli": "^1.5.14", "@tauri-apps/cli": "^1.5.14",
"@vitejs/plugin-react": "^4.2.1", "@vitejs/plugin-react": "^4.3.0",
"prop-types": "^15.8.1", "prop-types": "^15.8.1",
"sass": "^1.77.1", "sass": "^1.77.2",
"vite": "^5.2.11", "vite": "^5.2.12",
"vite-plugin-compression": "^0.5.1" "vite-plugin-compression": "^0.5.1"
}, },
"license": "GPL-3.0-only" "license": "GPL-3.0-only"
+905 -1418
View File
File diff suppressed because it is too large. Load diff
+2 -10
View File
@@ -93,7 +93,6 @@ export const AppBar = () => {
const navigate = useNavigate(); const navigate = useNavigate();
const [display, setDisplay] = useState(false); const [display, setDisplay] = useState(false);
const [backButtonVisible, setBackButtonVisible] = useState(false);
const location = useLocation(); const location = useLocation();
@@ -133,8 +132,6 @@ export const AppBar = () => {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const [tabValue] = useSettingsStore((state) => [state.tabValue]);
const handleLogout = async () => { const handleLogout = async () => {
console.log("Logging out user..."); console.log("Logging out user...");
await api.logout(); await api.logout();
@@ -160,11 +157,6 @@ export const AppBar = () => {
setDisplay(true); setDisplay(true);
} }
if (location.pathname === "/home") {
setBackButtonVisible(false);
} else {
setBackButtonVisible(true);
}
}, [location]); }, [location]);
const [showDrawer, setShowDrawer] = useState(false); const [showDrawer, setShowDrawer] = useState(false);
@@ -207,10 +199,10 @@ export const AppBar = () => {
</div> </div>
<div className="flex flex-row" style={{ gap: "0.6em" }}> <div className="flex flex-row" style={{ gap: "0.6em" }}>
<IconButton onClick={() => navigate("/search")}> <IconButton onClick={() => navigate({ to: "/search" })}>
<div className="material-symbols-rounded">search</div> <div className="material-symbols-rounded">search</div>
</IconButton> </IconButton>
<IconButton onClick={() => navigate("/favorite")}> <IconButton onClick={() => navigate({ to: "/favorite" })}>
<div className="material-symbols-rounded">favorite</div> <div className="material-symbols-rounded">favorite</div>
</IconButton> </IconButton>
<IconButton sx={{ p: 0 }} onClick={handleMenuOpen}> <IconButton sx={{ p: 0 }} onClick={handleMenuOpen}>
@@ -1,3 +1,4 @@
import { useApiInContext } from "@/utils/store/api";
import { playItemFromQueue } from "@/utils/store/playback"; import { playItemFromQueue } from "@/utils/store/playback";
import useQueue from "@/utils/store/queue"; import useQueue from "@/utils/store/queue";
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api"; import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
+1
View File
@@ -13,6 +13,7 @@ import { getTypeIcon } from "../utils/iconsCollection";
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api"; import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
import { useMutation, useQuery } from "@tanstack/react-query"; import { useMutation, useQuery } from "@tanstack/react-query";
import "./queueButton.scss"; import "./queueButton.scss";
import { useApiInContext } from "@/utils/store/api";
import { useRouteContext } from "@tanstack/react-router"; import { useRouteContext } from "@tanstack/react-router";
const QueueButton = () => { const QueueButton = () => {
const api = useApiInContext((s) => s.api); const api = useApiInContext((s) => s.api);
+26 -8
View File
@@ -64,14 +64,32 @@ export const Card = ({
const api = useApiInContext((s) => s.api); const api = useApiInContext((s) => s.api);
const navigate = useNavigate(); const navigate = useNavigate();
const defaultOnClick = () => { const defaultOnClick = () => {
if (availableSpecialRoutes.includes(item.Type)) {
navigate({ to: `/${item.Type.toLocaleLowerCase()}/${item.Id}` }); switch (item.Type) {
} else if (!!item.Role || item.Type === BaseItemKind.Person) { case BaseItemKind.BoxSet:
navigate({ to: `/person/${item.Id}` }); navigate({ to: "/boxset/$id", params: { id: item.Id } });
} else if (item.Type === BaseItemKind.MusicArtist) { break;
navigate({ to: `/artist/${item.Id}` }); case BaseItemKind.Episode:
} else { navigate({ to: "/episode/$id", params: { id: item.Id } });
navigate({ to: `/item/${item.Id}` }); break;
case BaseItemKind.MusicAlbum:
navigate({ to: "/album/$id", params: { id: item.Id } });
break;
case BaseItemKind.MusicArtist:
navigate({ to: "/artist/$id", params: { id: item.Id } });
break;
case BaseItemKind.Person:
navigate({ to: "/person/$id", params: { id: item.Id } });
break;
case BaseItemKind.Series:
navigate({ to: "/series/$id", params: { id: item.Id } });
break;
case BaseItemKind.Playlist:
navigate({ to: "/playlist/$id", params: { id: item.Id } });
break;
default:
navigate({ to: "/item/$id", params: { id: item.Id } });
break;
} }
}; };
@@ -17,10 +17,11 @@ import PlayButton from "../../buttons/playButton";
import TrackList from "../tracksList/index"; import TrackList from "../tracksList/index";
import "./albumArtist.scss"; import "./albumArtist.scss";
import { useApiInContext } from "@/utils/store/api";
import { Link, useRouteContext } from "@tanstack/react-router"; import { Link, useRouteContext } from "@tanstack/react-router";
export const ArtistAlbum = ({ user, album, boxProps }) => { export const ArtistAlbum = ({ user, album, boxProps }) => {
const api = useRouteContext({ from: "/" }).api; const api = useApiInContext((s) => s.api);
const albumTracks = useQuery({ const albumTracks = useQuery({
queryKey: ["artist", "album", album.Id], queryKey: ["artist", "album", album.Id],
queryFn: async () => { queryFn: async () => {
@@ -56,16 +56,18 @@ export const LatestMediaSection = ({ latestMediaLib }) => {
imageType={"Primary"} imageType={"Primary"}
cardCaption={ cardCaption={
item.Type === BaseItemKind.Episode item.Type === BaseItemKind.Episode
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}` ? `S${item.ParentIndexNumber ?? 0}:E${
item.IndexNumber ?? 0
} - ${item.Name ?? "Unknown"}`
: item.Type === BaseItemKind.Series : item.Type === BaseItemKind.Series
? `${item.ProductionYear} - ${ ? `${item.ProductionYear} - ${
item.EndDate item.EndDate
? new Date(item.EndDate).toLocaleString([], { ? new Date(item.EndDate).toLocaleString([], {
year: "numeric", year: "numeric",
}) })
: "Present" : "Present"
}` }`
: item.ProductionYear : item.ProductionYear
} }
cardType={ cardType={
item.Type === BaseItemKind.MusicAlbum || item.Type === BaseItemKind.MusicAlbum ||
+5 -4
View File
@@ -8,6 +8,7 @@ import { getRuntimeMusic } from "../../../utils/date/time";
import { useAudioPlayback } from "../../../utils/store/audioPlayback"; import { useAudioPlayback } from "../../../utils/store/audioPlayback";
import LikeButton from "../../buttons/likeButton"; import LikeButton from "../../buttons/likeButton";
import "./tracksList.scss"; import "./tracksList.scss";
import { useApiInContext } from "@/utils/store/api";
import { useRouteContext } from "@tanstack/react-router"; import { useRouteContext } from "@tanstack/react-router";
export default function TracksList({ export default function TracksList({
@@ -15,7 +16,7 @@ export default function TracksList({
user, user,
queryKey, queryKey,
}: { tracks: BaseItemDto[]; user: UserDto; queryKey: [] }) { }: { tracks: BaseItemDto[]; user: UserDto; queryKey: [] }) {
const api = useRouteContext({ from: "/" }).api; const api = useApiInContext((s) => s.api);
const [ const [
currentItem, currentItem,
@@ -58,11 +59,11 @@ export default function TracksList({
</div> </div>
{tracks.map((track, index) => ( {tracks.map((track, index) => (
<div <div
className={currentItem.Id === track.Id ? "track playing" : "track"} className={currentItem?.Id === track.Id ? "track playing" : "track"}
key={track.Id} key={track.Id}
onClick={() => playTrack(index)} onClick={() => playTrack(index)}
> >
{currentItem.Id === track.Id ? ( {currentItem?.Id === track.Id ? (
<span className="material-symbols-rounded ">equalizer</span> <span className="material-symbols-rounded ">equalizer</span>
) : ( ) : (
<Typography>{track.IndexNumber ?? "-"}</Typography> <Typography>{track.IndexNumber ?? "-"}</Typography>
@@ -81,7 +82,7 @@ export default function TracksList({
> >
{track.Name} {track.Name}
</Typography> </Typography>
<Typography>{getRuntimeMusic(track.RunTimeTicks)}</Typography> <Typography>{getRuntimeMusic(track?.RunTimeTicks)}</Typography>
</div> </div>
))} ))}
</div> </div>
+3 -2
View File
@@ -6,6 +6,7 @@ import LikeButton from "../buttons/likeButton";
import PlayButton from "../buttons/playButton"; import PlayButton from "../buttons/playButton";
import TextLink from "../textLink"; import TextLink from "../textLink";
import "./musicTrack.scss"; import "./musicTrack.scss";
import { useApiInContext } from "@/utils/store/api";
import { useRouteContext } from "@tanstack/react-router"; import { useRouteContext } from "@tanstack/react-router";
/** /**
@@ -33,7 +34,7 @@ const MusicTrack = ({
trackIndex, trackIndex,
className = "", className = "",
}) => { }) => {
const api = useRouteContext({ from: "/" }).api; const api = useApiInContext((s) => s.api);
const [currentTrackItem] = useAudioPlayback((state) => [state.item]); const [currentTrackItem] = useAudioPlayback((state) => [state.item]);
return ( return (
@@ -87,7 +88,7 @@ const MusicTrack = ({
variant="subtitle1" variant="subtitle1"
style={{ style={{
color: color:
item.Id === currentTrackItem.Id ? "hsl(337, 96%, 56%)" : "white", item.Id === currentTrackItem?.Id ? "hsl(337, 96%, 56%)" : "white",
}} }}
> >
{item.Name} {item.Name}
+10 -5
View File
@@ -432,10 +432,13 @@ const Settings = () => {
<Typography variant="subtitle2">Client Version:</Typography> <Typography variant="subtitle2">Client Version:</Typography>
<Chip <Chip
icon={ icon={
<span className="material-symbols-rounded"> <span
className="material-symbols-rounded"
style={{ "--wght": 500 }}
>
{updateInfo.data?.shouldUpdate {updateInfo.data?.shouldUpdate
? "update" ? "new_release"
: "update_disabled"} : "new_releases"}
</span> </span>
} }
label={ label={
@@ -443,7 +446,9 @@ const Settings = () => {
{applicationVersion} {applicationVersion}
</Typography> </Typography>
} }
color={updateInfo.data?.shouldUpdate ? "error" : "info"} color={
updateInfo.data?.shouldUpdate ? "error" : "success"
}
size="small" size="small"
style={{ style={{
width: "fit-content !important", width: "fit-content !important",
@@ -461,7 +466,7 @@ const Settings = () => {
<Chip <Chip
icon={ icon={
<span className="material-symbols-rounded"> <span className="material-symbols-rounded">
update new_releases
</span> </span>
} }
label={ label={
+129 -10
View File
@@ -264,36 +264,36 @@ declare module '@tanstack/react-router' {
} }
'/_api/favorite/': { '/_api/favorite/': {
id: '/_api/favorite/' id: '/_api/favorite/'
path: '/favorite/' path: '/favorite'
fullPath: '/favorite/' fullPath: '/favorite'
preLoaderRoute: typeof ApiFavoriteIndexImport preLoaderRoute: typeof ApiFavoriteIndexImport
parentRoute: typeof ApiImport parentRoute: typeof ApiImport
} }
'/_api/home/': { '/_api/home/': {
id: '/_api/home/' id: '/_api/home/'
path: '/home/' path: '/home'
fullPath: '/home/' fullPath: '/home'
preLoaderRoute: typeof ApiHomeIndexImport preLoaderRoute: typeof ApiHomeIndexImport
parentRoute: typeof ApiImport parentRoute: typeof ApiImport
} }
'/_api/login/': { '/_api/login/': {
id: '/_api/login/' id: '/_api/login/'
path: '/login/' path: '/login'
fullPath: '/login/' fullPath: '/login'
preLoaderRoute: typeof ApiLoginIndexImport preLoaderRoute: typeof ApiLoginIndexImport
parentRoute: typeof ApiImport parentRoute: typeof ApiImport
} }
'/_api/player/': { '/_api/player/': {
id: '/_api/player/' id: '/_api/player/'
path: '/player/' path: '/player'
fullPath: '/player/' fullPath: '/player'
preLoaderRoute: typeof ApiPlayerIndexImport preLoaderRoute: typeof ApiPlayerIndexImport
parentRoute: typeof ApiImport parentRoute: typeof ApiImport
} }
'/_api/search/': { '/_api/search/': {
id: '/_api/search/' id: '/_api/search/'
path: '/search/' path: '/search'
fullPath: '/search/' fullPath: '/search'
preLoaderRoute: typeof ApiSearchIndexImport preLoaderRoute: typeof ApiSearchIndexImport
parentRoute: typeof ApiImport parentRoute: typeof ApiImport
} }
@@ -336,3 +336,122 @@ export const routeTree = rootRoute.addChildren({
}) })
/* prettier-ignore-end */ /* prettier-ignore-end */
/* ROUTE_MANIFEST_START
{
"routes": {
"__root__": {
"filePath": "__root.tsx",
"children": [
"/",
"/_api",
"/setup/server/add",
"/setup/server/error",
"/setup/server/list"
]
},
"/": {
"filePath": "index.tsx"
},
"/_api": {
"filePath": "_api.tsx",
"children": [
"/_api/album/$id",
"/_api/artist/$id",
"/_api/boxset/$id",
"/_api/episode/$id",
"/_api/item/$id",
"/_api/library/$id",
"/_api/login/list",
"/_api/login/manual",
"/_api/person/$id",
"/_api/playlist/$id",
"/_api/series/$id",
"/_api/favorite/",
"/_api/home/",
"/_api/login/",
"/_api/player/",
"/_api/search/",
"/_api/login/$userId/$userName"
]
},
"/_api/album/$id": {
"filePath": "_api/album/$id.tsx",
"parent": "/_api"
},
"/_api/artist/$id": {
"filePath": "_api/artist/$id.tsx",
"parent": "/_api"
},
"/_api/boxset/$id": {
"filePath": "_api/boxset/$id.tsx",
"parent": "/_api"
},
"/_api/episode/$id": {
"filePath": "_api/episode/$id.tsx",
"parent": "/_api"
},
"/_api/item/$id": {
"filePath": "_api/item/$id.tsx",
"parent": "/_api"
},
"/_api/library/$id": {
"filePath": "_api/library/$id.tsx",
"parent": "/_api"
},
"/_api/login/list": {
"filePath": "_api/login/list.tsx",
"parent": "/_api"
},
"/_api/login/manual": {
"filePath": "_api/login/manual.tsx",
"parent": "/_api"
},
"/_api/person/$id": {
"filePath": "_api/person/$id.tsx",
"parent": "/_api"
},
"/_api/playlist/$id": {
"filePath": "_api/playlist/$id.jsx",
"parent": "/_api"
},
"/_api/series/$id": {
"filePath": "_api/series/$id.tsx",
"parent": "/_api"
},
"/setup/server/add": {
"filePath": "setup/server.add.tsx"
},
"/setup/server/error": {
"filePath": "setup/server.error.tsx"
},
"/setup/server/list": {
"filePath": "setup/server.list.tsx"
},
"/_api/favorite/": {
"filePath": "_api/favorite/index.tsx",
"parent": "/_api"
},
"/_api/home/": {
"filePath": "_api/home/index.tsx",
"parent": "/_api"
},
"/_api/login/": {
"filePath": "_api/login/index.tsx",
"parent": "/_api"
},
"/_api/player/": {
"filePath": "_api/player/index.tsx",
"parent": "/_api"
},
"/_api/search/": {
"filePath": "_api/search/index.jsx",
"parent": "/_api"
},
"/_api/login/$userId/$userName": {
"filePath": "_api/login/$userId.$userName.tsx",
"parent": "/_api"
}
}
}
ROUTE_MANIFEST_END */
+3
View File
@@ -22,6 +22,7 @@ import {
import { useIsFetching, useIsMutating } from "@tanstack/react-query"; import { useIsFetching, useIsMutating } from "@tanstack/react-query";
import { import {
Outlet, Outlet,
ScrollRestoration,
createRootRoute, createRootRoute,
createRootRouteWithContext, createRootRouteWithContext,
useNavigate, useNavigate,
@@ -64,6 +65,7 @@ export const Route = createRootRouteWithContext<ApiContext>()({
console.error(error.error); console.error(error.error);
}, },
component: () => { component: () => {
"use memo";
const isQueryFetching = useIsFetching(); const isQueryFetching = useIsFetching();
const isMutating = useIsMutating(); const isMutating = useIsMutating();
const routeIsLoading = useRouterState().isLoading; const routeIsLoading = useRouterState().isLoading;
@@ -107,6 +109,7 @@ export const Route = createRootRouteWithContext<ApiContext>()({
<ThemeProvider theme={theme}> <ThemeProvider theme={theme}>
<SnackbarProvider maxSnack={5}> <SnackbarProvider maxSnack={5}>
<CssBaseline /> <CssBaseline />
<ScrollRestoration />
<Settings /> <Settings />
<EasterEgg /> <EasterEgg />
<NProgress <NProgress
+13 -12
View File
@@ -29,22 +29,23 @@ export const Route = createFileRoute("/_api")({
try { try {
await getSystemApi(context.api).getPingSystem(); // Verify server status await getSystemApi(context.api).getPingSystem(); // Verify server status
} catch (error) { } catch (error) {
console.error(error);
throw redirect({ throw redirect({
to: "/setup/server/error", to: "/setup/server/error",
search: {
redirect: location.href,
},
}); });
} }
try { if (context.api.accessToken) {
await getUserApi(context.api).getCurrentUser(); // Verify user is able to authenticate try {
} catch (error) { await getUserApi(context.api).getCurrentUser(); // Verify user is able to authenticate
throw redirect({ } catch (error) {
to: "/login/manual", console.error(error);
search: { throw redirect({
redirect: location.href, to: "/login/manual",
}, search: {
}); redirect: location.href,
},
});
}
} }
} }
}, },
+7 -4
View File
@@ -38,7 +38,7 @@ import { useBackdropStore } from "@/utils/store/backdrop";
import "./album.scss"; import "./album.scss";
import IconLink from "@/components/iconLink"; import IconLink from "@/components/iconLink";
import { createFileRoute } from "@tanstack/react-router"; import { Link, createFileRoute } from "@tanstack/react-router";
function TabPanel(props) { function TabPanel(props) {
const { children, value, index, ...other } = props; const { children, value, index, ...other } = props;
@@ -387,10 +387,13 @@ function MusicAlbumTitlePage() {
</Typography> </Typography>
<div className="item-detail-cast-grid"> <div className="item-detail-cast-grid">
{item.data.ArtistItems.map((artist) => ( {item.data.ArtistItems.map((artist) => (
<NavLink <Link
className="item-detail-cast-card" className="item-detail-cast-card"
key={artist.Id} key={artist.Id}
to={`/artist/${artist.Id}`} to="/artist/$id"
params={{
id: artist.Id,
}}
> >
<div <div
style={{ style={{
@@ -430,7 +433,7 @@ function MusicAlbumTitlePage() {
{artist.Role} {artist.Role}
</Typography> </Typography>
</div> </div>
</NavLink> </Link>
))} ))}
</div> </div>
</div> </div>
+1 -1
View File
@@ -36,7 +36,7 @@ export const Route = createFileRoute("/_api/home/")({
}); });
function Home() { function Home() {
const api = Route.useRouteContext().api; const api = useApiInContext((s) => s.api);
const user = useQuery({ const user = useQuery({
queryKey: ["user"], queryKey: ["user"],
+1
View File
@@ -97,6 +97,7 @@ export const Route = createFileRoute("/_api/item/$id")({
}); });
function ItemDetail() { function ItemDetail() {
"use memo";
const { id } = Route.useParams(); const { id } = Route.useParams();
const api = Route.useRouteContext().api; const api = Route.useRouteContext().api;
+6 -1
View File
@@ -965,7 +965,12 @@ function SeriesTitlePage() {
return ( return (
<motion.div <motion.div
key={episode.Id} key={episode.Id}
onClick={() => navigate(`/episode/${episode.Id}`)} onClick={() =>
navigate({
to: "/episode/$id",
params: { id: episode.Id },
})
}
initial={{ initial={{
transform: "translateY(10px)", transform: "translateY(10px)",
opacity: 0, opacity: 0,
+16
View File
@@ -0,0 +1,16 @@
.server-error {
&-container {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
gap: 1em;
.material-symbols-rounded {
font-size: 10em;
// --wght: 500;
// --opsz: 40
}
}
}
+31 -2
View File
@@ -1,6 +1,35 @@
import { createFileRoute } from "@tanstack/react-router"; import { Link, createFileRoute, useNavigate } from "@tanstack/react-router";
import React from "react"; import React from "react";
import "./server.error.scss";
import { Button, ButtonGroup, Typography } from "@mui/material";
import { relaunch } from "@tauri-apps/api/process";
export const Route = createFileRoute("/setup/server/error")({ export const Route = createFileRoute("/setup/server/error")({
component: () => <div>Hello /setup/server/error!</div>, component: () => {
const navigate = useNavigate();
return (
<div className="scrollY server-error-container">
<span className="material-symbols-rounded fill gradient-text">
report
</span>
<Typography variant="h4">Unable to connect to server!</Typography>
<div className="flex flex-align-center" style={{ gap: "1em" }}>
<Button
variant="contained"
onClick={() => navigate({ to: "/setup/server/list" })}
>
Change Server
</Button>
<Button
variant="contained"
color="secondary"
onClick={async () => await relaunch()}
>
Restart Blink
</Button>
</div>
</div>
);
},
}); });
+2 -1
View File
@@ -5,7 +5,8 @@ import { TanStackRouterVite } from '@tanstack/router-vite-plugin'
import MillionLint from '@million/lint'; import MillionLint from '@million/lint';
import path from "path"; import path from "path";
// https://vitejs.dev/config/ // const ReactCompilerConfig = {compilationMode: "annotation"}
const plugins = [MillionLint.vite(),react(), svgr(), TanStackRouterVite()]; const plugins = [MillionLint.vite(),react(), svgr(), TanStackRouterVite()];
export default defineConfig({ export default defineConfig({
plugins: plugins, plugins: plugins,