refactor: cleanup search route
This commit is contained in:
6 files changed
+83
-130
No files matched your search
@@ -68,6 +68,7 @@ const Settings = () => {
|
|||||||
const systemInfo = useQuery({
|
const systemInfo = useQuery({
|
||||||
queryKey: ["about", "systemInfo"],
|
queryKey: ["about", "systemInfo"],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getSystemApi(api).getSystemInfo();
|
const result = await getSystemApi(api).getSystemInfo();
|
||||||
return result.data;
|
return result.data;
|
||||||
},
|
},
|
||||||
@@ -106,7 +107,7 @@ const Settings = () => {
|
|||||||
const handleServerChange = useMutation({
|
const handleServerChange = useMutation({
|
||||||
mutationFn: async (server: RecommendedServerInfo) => {
|
mutationFn: async (server: RecommendedServerInfo) => {
|
||||||
await delUser();
|
await delUser();
|
||||||
await setDefaultServer(server.id);
|
await setDefaultServer(server.systemInfo?.Id ?? "");
|
||||||
await defaultServer.refetch();
|
await defaultServer.refetch();
|
||||||
createApi(server.address, undefined);
|
createApi(server.address, undefined);
|
||||||
queryClient.removeQueries();
|
queryClient.removeQueries();
|
||||||
@@ -126,15 +127,15 @@ const Settings = () => {
|
|||||||
const handleDelete = useMutation({
|
const handleDelete = useMutation({
|
||||||
mutationKey: ["server-delete"],
|
mutationKey: ["server-delete"],
|
||||||
mutationFn: async (server: RecommendedServerInfo) => {
|
mutationFn: async (server: RecommendedServerInfo) => {
|
||||||
await delServer(server.id);
|
await delServer(server.systemInfo?.Id ?? "");
|
||||||
|
|
||||||
if (server.id === defaultServer.data) {
|
if (server.systemInfo?.Id === defaultServer.data) {
|
||||||
await delUser();
|
await delUser();
|
||||||
await serversOnDisk.refetch();
|
await serversOnDisk.refetch();
|
||||||
|
|
||||||
if (serversOnDisk.data.length > 0) {
|
if (serversOnDisk.data?.length) {
|
||||||
setDefaultServer(serversOnDisk.data[0].id);
|
setDefaultServer(serversOnDisk.data[0].id);
|
||||||
createApi(serversOnDisk.data[0].address, null);
|
createApi(serversOnDisk.data[0].address, undefined);
|
||||||
} else {
|
} else {
|
||||||
// TODO: Reset api in context
|
// TODO: Reset api in context
|
||||||
// useApi.setState(useApi.getInitialState());
|
// useApi.setState(useApi.getInitialState());
|
||||||
@@ -158,7 +159,7 @@ const Settings = () => {
|
|||||||
},
|
},
|
||||||
onSuccess: async (bestServer) => {
|
onSuccess: async (bestServer) => {
|
||||||
if (bestServer) {
|
if (bestServer) {
|
||||||
await setServer(bestServer.systemInfo.Id, bestServer);
|
await setServer(bestServer.systemInfo?.Id ?? "", bestServer);
|
||||||
setAddServerDialog(false);
|
setAddServerDialog(false);
|
||||||
enqueueSnackbar(
|
enqueueSnackbar(
|
||||||
"Client added successfully. You might need to refresh client list.",
|
"Client added successfully. You might need to refresh client list.",
|
||||||
@@ -620,6 +621,7 @@ const Settings = () => {
|
|||||||
>
|
>
|
||||||
Close
|
Close
|
||||||
</Button>
|
</Button>
|
||||||
|
{/* @ts-ignore */}
|
||||||
<LoadingButton
|
<LoadingButton
|
||||||
startIcon={
|
startIcon={
|
||||||
<span
|
<span
|
||||||
|
|||||||
+13
-50
@@ -14,7 +14,6 @@ import { Route as rootRoute } from './routes/__root'
|
|||||||
import { Route as ApiImport } from './routes/_api'
|
import { Route as ApiImport } from './routes/_api'
|
||||||
import { Route as IndexImport } from './routes/index'
|
import { Route as IndexImport } from './routes/index'
|
||||||
import { Route as ErrorCodeImport } from './routes/error/$code'
|
import { Route as ErrorCodeImport } from './routes/error/$code'
|
||||||
import { Route as ApiSearchImport } from './routes/_api/search'
|
|
||||||
import { Route as ApiLoginImport } from './routes/_api/login'
|
import { Route as ApiLoginImport } from './routes/_api/login'
|
||||||
import { Route as ApiSearchIndexImport } from './routes/_api/search/index'
|
import { Route as ApiSearchIndexImport } from './routes/_api/search/index'
|
||||||
import { Route as ApiPlayerIndexImport } from './routes/_api/player/index'
|
import { Route as ApiPlayerIndexImport } from './routes/_api/player/index'
|
||||||
@@ -57,12 +56,6 @@ const ErrorCodeRoute = ErrorCodeImport.update({
|
|||||||
getParentRoute: () => rootRoute,
|
getParentRoute: () => rootRoute,
|
||||||
} as any)
|
} as any)
|
||||||
|
|
||||||
const ApiSearchRoute = ApiSearchImport.update({
|
|
||||||
id: '/search',
|
|
||||||
path: '/search',
|
|
||||||
getParentRoute: () => ApiRoute,
|
|
||||||
} as any)
|
|
||||||
|
|
||||||
const ApiLoginRoute = ApiLoginImport.update({
|
const ApiLoginRoute = ApiLoginImport.update({
|
||||||
id: '/login',
|
id: '/login',
|
||||||
path: '/login',
|
path: '/login',
|
||||||
@@ -70,9 +63,9 @@ const ApiLoginRoute = ApiLoginImport.update({
|
|||||||
} as any)
|
} as any)
|
||||||
|
|
||||||
const ApiSearchIndexRoute = ApiSearchIndexImport.update({
|
const ApiSearchIndexRoute = ApiSearchIndexImport.update({
|
||||||
id: '/',
|
id: '/search/',
|
||||||
path: '/',
|
path: '/search/',
|
||||||
getParentRoute: () => ApiSearchRoute,
|
getParentRoute: () => ApiRoute,
|
||||||
} as any)
|
} as any)
|
||||||
|
|
||||||
const ApiPlayerIndexRoute = ApiPlayerIndexImport.update({
|
const ApiPlayerIndexRoute = ApiPlayerIndexImport.update({
|
||||||
@@ -220,13 +213,6 @@ declare module '@tanstack/react-router' {
|
|||||||
preLoaderRoute: typeof ApiLoginImport
|
preLoaderRoute: typeof ApiLoginImport
|
||||||
parentRoute: typeof ApiImport
|
parentRoute: typeof ApiImport
|
||||||
}
|
}
|
||||||
'/_api/search': {
|
|
||||||
id: '/_api/search'
|
|
||||||
path: '/search'
|
|
||||||
fullPath: '/search'
|
|
||||||
preLoaderRoute: typeof ApiSearchImport
|
|
||||||
parentRoute: typeof ApiImport
|
|
||||||
}
|
|
||||||
'/error/$code': {
|
'/error/$code': {
|
||||||
id: '/error/$code'
|
id: '/error/$code'
|
||||||
path: '/error/$code'
|
path: '/error/$code'
|
||||||
@@ -369,10 +355,10 @@ declare module '@tanstack/react-router' {
|
|||||||
}
|
}
|
||||||
'/_api/search/': {
|
'/_api/search/': {
|
||||||
id: '/_api/search/'
|
id: '/_api/search/'
|
||||||
path: '/'
|
path: '/search'
|
||||||
fullPath: '/search/'
|
fullPath: '/search'
|
||||||
preLoaderRoute: typeof ApiSearchIndexImport
|
preLoaderRoute: typeof ApiSearchIndexImport
|
||||||
parentRoute: typeof ApiSearchImport
|
parentRoute: typeof ApiImport
|
||||||
}
|
}
|
||||||
'/_api/login/$userId/$userName': {
|
'/_api/login/$userId/$userName': {
|
||||||
id: '/_api/login/$userId/$userName'
|
id: '/_api/login/$userId/$userName'
|
||||||
@@ -402,21 +388,8 @@ const ApiLoginRouteWithChildren = ApiLoginRoute._addFileChildren(
|
|||||||
ApiLoginRouteChildren,
|
ApiLoginRouteChildren,
|
||||||
)
|
)
|
||||||
|
|
||||||
interface ApiSearchRouteChildren {
|
|
||||||
ApiSearchIndexRoute: typeof ApiSearchIndexRoute
|
|
||||||
}
|
|
||||||
|
|
||||||
const ApiSearchRouteChildren: ApiSearchRouteChildren = {
|
|
||||||
ApiSearchIndexRoute: ApiSearchIndexRoute,
|
|
||||||
}
|
|
||||||
|
|
||||||
const ApiSearchRouteWithChildren = ApiSearchRoute._addFileChildren(
|
|
||||||
ApiSearchRouteChildren,
|
|
||||||
)
|
|
||||||
|
|
||||||
interface ApiRouteChildren {
|
interface ApiRouteChildren {
|
||||||
ApiLoginRoute: typeof ApiLoginRouteWithChildren
|
ApiLoginRoute: typeof ApiLoginRouteWithChildren
|
||||||
ApiSearchRoute: typeof ApiSearchRouteWithChildren
|
|
||||||
ApiAlbumIdRoute: typeof ApiAlbumIdRoute
|
ApiAlbumIdRoute: typeof ApiAlbumIdRoute
|
||||||
ApiArtistIdRoute: typeof ApiArtistIdRoute
|
ApiArtistIdRoute: typeof ApiArtistIdRoute
|
||||||
ApiBoxsetIdRoute: typeof ApiBoxsetIdRoute
|
ApiBoxsetIdRoute: typeof ApiBoxsetIdRoute
|
||||||
@@ -431,11 +404,11 @@ interface ApiRouteChildren {
|
|||||||
ApiFavoriteIndexRoute: typeof ApiFavoriteIndexRoute
|
ApiFavoriteIndexRoute: typeof ApiFavoriteIndexRoute
|
||||||
ApiHomeIndexRoute: typeof ApiHomeIndexRoute
|
ApiHomeIndexRoute: typeof ApiHomeIndexRoute
|
||||||
ApiPlayerIndexRoute: typeof ApiPlayerIndexRoute
|
ApiPlayerIndexRoute: typeof ApiPlayerIndexRoute
|
||||||
|
ApiSearchIndexRoute: typeof ApiSearchIndexRoute
|
||||||
}
|
}
|
||||||
|
|
||||||
const ApiRouteChildren: ApiRouteChildren = {
|
const ApiRouteChildren: ApiRouteChildren = {
|
||||||
ApiLoginRoute: ApiLoginRouteWithChildren,
|
ApiLoginRoute: ApiLoginRouteWithChildren,
|
||||||
ApiSearchRoute: ApiSearchRouteWithChildren,
|
|
||||||
ApiAlbumIdRoute: ApiAlbumIdRoute,
|
ApiAlbumIdRoute: ApiAlbumIdRoute,
|
||||||
ApiArtistIdRoute: ApiArtistIdRoute,
|
ApiArtistIdRoute: ApiArtistIdRoute,
|
||||||
ApiBoxsetIdRoute: ApiBoxsetIdRoute,
|
ApiBoxsetIdRoute: ApiBoxsetIdRoute,
|
||||||
@@ -450,6 +423,7 @@ const ApiRouteChildren: ApiRouteChildren = {
|
|||||||
ApiFavoriteIndexRoute: ApiFavoriteIndexRoute,
|
ApiFavoriteIndexRoute: ApiFavoriteIndexRoute,
|
||||||
ApiHomeIndexRoute: ApiHomeIndexRoute,
|
ApiHomeIndexRoute: ApiHomeIndexRoute,
|
||||||
ApiPlayerIndexRoute: ApiPlayerIndexRoute,
|
ApiPlayerIndexRoute: ApiPlayerIndexRoute,
|
||||||
|
ApiSearchIndexRoute: ApiSearchIndexRoute,
|
||||||
}
|
}
|
||||||
|
|
||||||
const ApiRouteWithChildren = ApiRoute._addFileChildren(ApiRouteChildren)
|
const ApiRouteWithChildren = ApiRoute._addFileChildren(ApiRouteChildren)
|
||||||
@@ -458,7 +432,6 @@ export interface FileRoutesByFullPath {
|
|||||||
'/': typeof IndexRoute
|
'/': typeof IndexRoute
|
||||||
'': typeof ApiRouteWithChildren
|
'': typeof ApiRouteWithChildren
|
||||||
'/login': typeof ApiLoginRouteWithChildren
|
'/login': typeof ApiLoginRouteWithChildren
|
||||||
'/search': typeof ApiSearchRouteWithChildren
|
|
||||||
'/error/$code': typeof ErrorCodeRoute
|
'/error/$code': typeof ErrorCodeRoute
|
||||||
'/album/$id': typeof ApiAlbumIdRoute
|
'/album/$id': typeof ApiAlbumIdRoute
|
||||||
'/artist/$id': typeof ApiArtistIdRoute
|
'/artist/$id': typeof ApiArtistIdRoute
|
||||||
@@ -479,7 +452,7 @@ export interface FileRoutesByFullPath {
|
|||||||
'/favorite': typeof ApiFavoriteIndexRoute
|
'/favorite': typeof ApiFavoriteIndexRoute
|
||||||
'/home': typeof ApiHomeIndexRoute
|
'/home': typeof ApiHomeIndexRoute
|
||||||
'/player': typeof ApiPlayerIndexRoute
|
'/player': typeof ApiPlayerIndexRoute
|
||||||
'/search/': typeof ApiSearchIndexRoute
|
'/search': typeof ApiSearchIndexRoute
|
||||||
'/login/$userId/$userName': typeof ApiLoginUserIdUserNameRoute
|
'/login/$userId/$userName': typeof ApiLoginUserIdUserNameRoute
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -516,7 +489,6 @@ export interface FileRoutesById {
|
|||||||
'/': typeof IndexRoute
|
'/': typeof IndexRoute
|
||||||
'/_api': typeof ApiRouteWithChildren
|
'/_api': typeof ApiRouteWithChildren
|
||||||
'/_api/login': typeof ApiLoginRouteWithChildren
|
'/_api/login': typeof ApiLoginRouteWithChildren
|
||||||
'/_api/search': typeof ApiSearchRouteWithChildren
|
|
||||||
'/error/$code': typeof ErrorCodeRoute
|
'/error/$code': typeof ErrorCodeRoute
|
||||||
'/_api/album/$id': typeof ApiAlbumIdRoute
|
'/_api/album/$id': typeof ApiAlbumIdRoute
|
||||||
'/_api/artist/$id': typeof ApiArtistIdRoute
|
'/_api/artist/$id': typeof ApiArtistIdRoute
|
||||||
@@ -547,7 +519,6 @@ export interface FileRouteTypes {
|
|||||||
| '/'
|
| '/'
|
||||||
| ''
|
| ''
|
||||||
| '/login'
|
| '/login'
|
||||||
| '/search'
|
|
||||||
| '/error/$code'
|
| '/error/$code'
|
||||||
| '/album/$id'
|
| '/album/$id'
|
||||||
| '/artist/$id'
|
| '/artist/$id'
|
||||||
@@ -568,7 +539,7 @@ export interface FileRouteTypes {
|
|||||||
| '/favorite'
|
| '/favorite'
|
||||||
| '/home'
|
| '/home'
|
||||||
| '/player'
|
| '/player'
|
||||||
| '/search/'
|
| '/search'
|
||||||
| '/login/$userId/$userName'
|
| '/login/$userId/$userName'
|
||||||
fileRoutesByTo: FileRoutesByTo
|
fileRoutesByTo: FileRoutesByTo
|
||||||
to:
|
to:
|
||||||
@@ -602,7 +573,6 @@ export interface FileRouteTypes {
|
|||||||
| '/'
|
| '/'
|
||||||
| '/_api'
|
| '/_api'
|
||||||
| '/_api/login'
|
| '/_api/login'
|
||||||
| '/_api/search'
|
|
||||||
| '/error/$code'
|
| '/error/$code'
|
||||||
| '/_api/album/$id'
|
| '/_api/album/$id'
|
||||||
| '/_api/artist/$id'
|
| '/_api/artist/$id'
|
||||||
@@ -671,7 +641,6 @@ export const routeTree = rootRoute
|
|||||||
"filePath": "_api.tsx",
|
"filePath": "_api.tsx",
|
||||||
"children": [
|
"children": [
|
||||||
"/_api/login",
|
"/_api/login",
|
||||||
"/_api/search",
|
|
||||||
"/_api/album/$id",
|
"/_api/album/$id",
|
||||||
"/_api/artist/$id",
|
"/_api/artist/$id",
|
||||||
"/_api/boxset/$id",
|
"/_api/boxset/$id",
|
||||||
@@ -685,7 +654,8 @@ export const routeTree = rootRoute
|
|||||||
"/_api/series/$id",
|
"/_api/series/$id",
|
||||||
"/_api/favorite/",
|
"/_api/favorite/",
|
||||||
"/_api/home/",
|
"/_api/home/",
|
||||||
"/_api/player/"
|
"/_api/player/",
|
||||||
|
"/_api/search/"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"/_api/login": {
|
"/_api/login": {
|
||||||
@@ -697,13 +667,6 @@ export const routeTree = rootRoute
|
|||||||
"/_api/login/$userId/$userName"
|
"/_api/login/$userId/$userName"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"/_api/search": {
|
|
||||||
"filePath": "_api/search.tsx",
|
|
||||||
"parent": "/_api",
|
|
||||||
"children": [
|
|
||||||
"/_api/search/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"/error/$code": {
|
"/error/$code": {
|
||||||
"filePath": "error/$code.tsx"
|
"filePath": "error/$code.tsx"
|
||||||
},
|
},
|
||||||
@@ -782,7 +745,7 @@ export const routeTree = rootRoute
|
|||||||
},
|
},
|
||||||
"/_api/search/": {
|
"/_api/search/": {
|
||||||
"filePath": "_api/search/index.tsx",
|
"filePath": "_api/search/index.tsx",
|
||||||
"parent": "/_api/search"
|
"parent": "/_api"
|
||||||
},
|
},
|
||||||
"/_api/login/$userId/$userName": {
|
"/_api/login/$userId/$userName": {
|
||||||
"filePath": "_api/login/$userId.$userName.tsx",
|
"filePath": "_api/login/$userId.$userName.tsx",
|
||||||
|
|||||||
@@ -152,7 +152,9 @@ function ItemDetail() {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
setSelectedVideoTrack(
|
setSelectedVideoTrack(
|
||||||
result?.find((track) => track.IsDefault)?.Index ?? result?.[0].Index ?? 0,
|
result?.find((track) => track.IsDefault)?.Index ??
|
||||||
|
result?.[0]?.Index ??
|
||||||
|
0,
|
||||||
);
|
);
|
||||||
return result ?? [];
|
return result ?? [];
|
||||||
}, [item.data?.Id]);
|
}, [item.data?.Id]);
|
||||||
@@ -164,7 +166,9 @@ function ItemDetail() {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
setSelectedAudioTrack(
|
setSelectedAudioTrack(
|
||||||
result?.find((track) => track.IsDefault)?.Index ?? result?.[0].Index ?? 0,
|
result?.find((track) => track.IsDefault)?.Index ??
|
||||||
|
result?.[0]?.Index ??
|
||||||
|
0,
|
||||||
);
|
);
|
||||||
return result ?? [];
|
return result ?? [];
|
||||||
}, [item.data?.Id]);
|
}, [item.data?.Id]);
|
||||||
@@ -672,6 +676,7 @@ function ItemDetail() {
|
|||||||
<PlayButton
|
<PlayButton
|
||||||
item={item.data}
|
item={item.data}
|
||||||
itemType={item.data.Type ?? "Movie"}
|
itemType={item.data.Type ?? "Movie"}
|
||||||
|
audio={item.data.Type === "Audio"}
|
||||||
currentVideoTrack={selectedVideoTrack}
|
currentVideoTrack={selectedVideoTrack}
|
||||||
currentAudioTrack={selectedAudioTrack}
|
currentAudioTrack={selectedAudioTrack}
|
||||||
currentSubTrack={selectedSubtitleTrack}
|
currentSubTrack={selectedSubtitleTrack}
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
import { createFileRoute } from "@tanstack/react-router";
|
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/search")({
|
|
||||||
validateSearch: (search: Record<string, string>): { query: string } => {
|
|
||||||
return {
|
|
||||||
query: search?.query as string,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
|
|
||||||
import CircularProgress from "@mui/material/CircularProgress";
|
|
||||||
import InputAdornment from "@mui/material/InputAdornment";
|
|
||||||
import TextField from "@mui/material/TextField";
|
import TextField from "@mui/material/TextField";
|
||||||
|
|
||||||
import { useBackdropStore } from "@/utils/store/backdrop";
|
import { useBackdropStore } from "@/utils/store/backdrop";
|
||||||
@@ -9,12 +7,8 @@ import { useBackdropStore } from "@/utils/store/backdrop";
|
|||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
|
||||||
import { EmptyNotice } from "@/components/notices/emptyNotice/emptyNotice";
|
import { EmptyNotice } from "@/components/notices/emptyNotice/emptyNotice";
|
||||||
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
|
||||||
|
|
||||||
import useDebounce from "@/utils/hooks/useDebounce";
|
|
||||||
|
|
||||||
import { Card } from "@/components/card/card";
|
import { Card } from "@/components/card/card";
|
||||||
import { EpisodeCard } from "@/components/card/episodeCard";
|
|
||||||
import CardScroller from "@/components/cardScroller/cardScroller";
|
import CardScroller from "@/components/cardScroller/cardScroller";
|
||||||
import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
||||||
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||||
@@ -22,7 +16,7 @@ import { getPersonsApi } from "@jellyfin/sdk/lib/utils/api/persons-api";
|
|||||||
import { getSearchApi } from "@jellyfin/sdk/lib/utils/api/search-api";
|
import { getSearchApi } from "@jellyfin/sdk/lib/utils/api/search-api";
|
||||||
import "./search.scss";
|
import "./search.scss";
|
||||||
import { useCentralStore } from "@/utils/store/central";
|
import { useCentralStore } from "@/utils/store/central";
|
||||||
import { Dialog, Fab } from "@mui/material";
|
import { Fab } from "@mui/material";
|
||||||
import { Outlet, createFileRoute, useNavigate } from "@tanstack/react-router";
|
import { Outlet, createFileRoute, useNavigate } from "@tanstack/react-router";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_api/search/")({
|
export const Route = createFileRoute("/_api/search/")({
|
||||||
@@ -48,6 +42,7 @@ function SearchPage() {
|
|||||||
const movies = useQuery({
|
const movies = useQuery({
|
||||||
queryKey: ["search", "items", "Movie", query],
|
queryKey: ["search", "items", "Movie", query],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
searchTerm: query,
|
searchTerm: query,
|
||||||
@@ -62,6 +57,7 @@ function SearchPage() {
|
|||||||
const series = useQuery({
|
const series = useQuery({
|
||||||
queryKey: ["search", "items", "Series", query],
|
queryKey: ["search", "items", "Series", query],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
searchTerm: query,
|
searchTerm: query,
|
||||||
@@ -76,6 +72,7 @@ function SearchPage() {
|
|||||||
const musicAlbum = useQuery({
|
const musicAlbum = useQuery({
|
||||||
queryKey: ["search", "items", "MusicAlbum", query],
|
queryKey: ["search", "items", "MusicAlbum", query],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
searchTerm: query,
|
searchTerm: query,
|
||||||
@@ -90,6 +87,7 @@ function SearchPage() {
|
|||||||
const audio = useQuery({
|
const audio = useQuery({
|
||||||
queryKey: ["search", "items", "Audio", query],
|
queryKey: ["search", "items", "Audio", query],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
searchTerm: query,
|
searchTerm: query,
|
||||||
@@ -104,6 +102,7 @@ function SearchPage() {
|
|||||||
const book = useQuery({
|
const book = useQuery({
|
||||||
queryKey: ["search", "items", "Book", query],
|
queryKey: ["search", "items", "Book", query],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
searchTerm: query,
|
searchTerm: query,
|
||||||
@@ -118,6 +117,7 @@ function SearchPage() {
|
|||||||
const musicArtists = useQuery({
|
const musicArtists = useQuery({
|
||||||
queryKey: ["search", "items", "MusicArtists", query],
|
queryKey: ["search", "items", "MusicArtists", query],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getItemsApi(api).getItems({
|
const result = await getItemsApi(api).getItems({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
searchTerm: query,
|
searchTerm: query,
|
||||||
@@ -132,6 +132,7 @@ function SearchPage() {
|
|||||||
const person = useQuery({
|
const person = useQuery({
|
||||||
queryKey: ["search", "items", "Person", query],
|
queryKey: ["search", "items", "Person", query],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getPersonsApi(api).getPersons({
|
const result = await getPersonsApi(api).getPersons({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
searchTerm: query,
|
searchTerm: query,
|
||||||
@@ -144,6 +145,7 @@ function SearchPage() {
|
|||||||
const episodes = useQuery({
|
const episodes = useQuery({
|
||||||
queryKey: ["search", "items", "Episodes", query],
|
queryKey: ["search", "items", "Episodes", query],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
if (!api) return null;
|
||||||
const result = await getSearchApi(api).getSearchHints({
|
const result = await getSearchApi(api).getSearchHints({
|
||||||
userId: user?.Id,
|
userId: user?.Id,
|
||||||
searchTerm: query,
|
searchTerm: query,
|
||||||
@@ -161,6 +163,7 @@ function SearchPage() {
|
|||||||
// Removing app's backdrop
|
// Removing app's backdrop
|
||||||
setBackdrop("", "");
|
setBackdrop("", "");
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="scrollY"
|
className="scrollY"
|
||||||
@@ -209,9 +212,9 @@ function SearchPage() {
|
|||||||
height: "100%",
|
height: "100%",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{movies.isSuccess && movies.data.Items.length > 0 && (
|
{movies.isSuccess && Boolean(movies.data?.Items?.length) && (
|
||||||
<CardScroller title="Movies" displayCards={8} disableDecoration>
|
<CardScroller title="Movies" displayCards={7} disableDecoration>
|
||||||
{movies.data.Items.map((item) => (
|
{movies.data?.Items?.map((item) => (
|
||||||
<Card
|
<Card
|
||||||
key={item.Id}
|
key={item.Id}
|
||||||
item={item}
|
item={item}
|
||||||
@@ -221,19 +224,13 @@ function SearchPage() {
|
|||||||
cardType="portrait"
|
cardType="portrait"
|
||||||
queryKey={["search", "items", "Movie", query]}
|
queryKey={["search", "items", "Movie", query]}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
|
||||||
!!item.ImageBlurHashes?.Primary &&
|
|
||||||
item.ImageBlurHashes?.Primary[
|
|
||||||
Object.keys(item.ImageBlurHashes.Primary)[0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</CardScroller>
|
</CardScroller>
|
||||||
)}
|
)}
|
||||||
{series.isSuccess && series.data.Items.length > 0 && (
|
{series.isSuccess && Boolean(series.data?.Items?.length) && (
|
||||||
<CardScroller title="TV Shows" displayCards={8} disableDecoration>
|
<CardScroller title="TV Shows" displayCards={7} disableDecoration>
|
||||||
{series.data.Items.map((item, index) => (
|
{series.data?.Items?.map((item) => (
|
||||||
<Card
|
<Card
|
||||||
key={item.Id}
|
key={item.Id}
|
||||||
item={item}
|
item={item}
|
||||||
@@ -249,19 +246,13 @@ function SearchPage() {
|
|||||||
cardType="portrait"
|
cardType="portrait"
|
||||||
queryKey={["search", "items", "Series", query]}
|
queryKey={["search", "items", "Series", query]}
|
||||||
userId={user?.Id}
|
userId={user?.Id}
|
||||||
imageBlurhash={
|
|
||||||
!!item.ImageBlurHashes?.Primary &&
|
|
||||||
item.ImageBlurHashes?.Primary[
|
|
||||||
Object.keys(item.ImageBlurHashes.Primary)[0]
|
|
||||||
]
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</CardScroller>
|
</CardScroller>
|
||||||
)}
|
)}
|
||||||
{episodes.isSuccess && episodes.data.TotalRecordCount > 0 && (
|
{episodes.isSuccess && Boolean(episodes.data?.TotalRecordCount) && (
|
||||||
<CardScroller title="Episodes" displayCards={4} disableDecoration>
|
<CardScroller title="Episodes" displayCards={4} disableDecoration>
|
||||||
{episodes.data.SearchHints?.map((episode) => {
|
{episodes.data?.SearchHints?.map((episode) => {
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
key={episode.Id}
|
key={episode.Id}
|
||||||
@@ -276,9 +267,9 @@ function SearchPage() {
|
|||||||
})}
|
})}
|
||||||
</CardScroller>
|
</CardScroller>
|
||||||
)}
|
)}
|
||||||
{audio.isSuccess && audio.data.Items?.length > 0 && (
|
{audio.isSuccess && Boolean(audio.data?.Items?.length) && (
|
||||||
<CardScroller title="Audio" displayCards={8} disableDecoration>
|
<CardScroller title="Audio" displayCards={7} disableDecoration>
|
||||||
{audio.data.Items?.map((item, index) => (
|
{audio.data?.Items?.map((item) => (
|
||||||
<Card
|
<Card
|
||||||
key={item.Id}
|
key={item.Id}
|
||||||
item={item}
|
item={item}
|
||||||
@@ -292,9 +283,9 @@ function SearchPage() {
|
|||||||
))}
|
))}
|
||||||
</CardScroller>
|
</CardScroller>
|
||||||
)}
|
)}
|
||||||
{musicAlbum.isSuccess && musicAlbum.data.Items?.length > 0 && (
|
{musicAlbum.isSuccess && Boolean(musicAlbum.data?.Items?.length) && (
|
||||||
<CardScroller title="Albums" displayCards={8} disableDecoration>
|
<CardScroller title="Albums" displayCards={7} disableDecoration>
|
||||||
{musicAlbum.data.Items?.map((item, index) => (
|
{musicAlbum.data?.Items?.map((item) => (
|
||||||
<Card
|
<Card
|
||||||
key={item.Id}
|
key={item.Id}
|
||||||
item={item}
|
item={item}
|
||||||
@@ -309,9 +300,9 @@ function SearchPage() {
|
|||||||
))}
|
))}
|
||||||
</CardScroller>
|
</CardScroller>
|
||||||
)}
|
)}
|
||||||
{book.isSuccess && book.data.Items?.length > 0 && (
|
{book.isSuccess && Boolean(book.data?.Items?.length) && (
|
||||||
<CardScroller title="Books" displayCards={8} disableDecoration>
|
<CardScroller title="Books" displayCards={7} disableDecoration>
|
||||||
{book.data.Items?.map((item, index) => (
|
{book.data?.Items?.map((item) => (
|
||||||
<Card
|
<Card
|
||||||
key={item.Id}
|
key={item.Id}
|
||||||
item={item}
|
item={item}
|
||||||
@@ -326,25 +317,26 @@ function SearchPage() {
|
|||||||
))}
|
))}
|
||||||
</CardScroller>
|
</CardScroller>
|
||||||
)}
|
)}
|
||||||
{musicArtists.isSuccess && musicArtists.data.Items?.length > 0 && (
|
{musicArtists.isSuccess &&
|
||||||
<CardScroller title="Artists" displayCards={8} disableDecoration>
|
Boolean(musicArtists.data?.Items?.length) && (
|
||||||
{musicArtists.data.Items?.map((item) => (
|
<CardScroller title="Artists" displayCards={7} disableDecoration>
|
||||||
<Card
|
{musicArtists.data?.Items?.map((item) => (
|
||||||
key={item.Id}
|
<Card
|
||||||
item={item}
|
key={item.Id}
|
||||||
cardTitle={item.Name}
|
item={item}
|
||||||
imageType={"Primary"}
|
cardTitle={item.Name}
|
||||||
disableOverlay
|
imageType={"Primary"}
|
||||||
cardType={"square"}
|
disableOverlay
|
||||||
queryKey={["search", "items", "MusicArtists", query]}
|
cardType={"square"}
|
||||||
userId={user?.Id}
|
queryKey={["search", "items", "MusicArtists", query]}
|
||||||
/>
|
userId={user?.Id}
|
||||||
))}
|
/>
|
||||||
</CardScroller>
|
))}
|
||||||
)}
|
</CardScroller>
|
||||||
{person.isSuccess && person.data.Items?.length > 0 && (
|
)}
|
||||||
<CardScroller title="People" displayCards={8} disableDecoration>
|
{person.isSuccess && Boolean(person.data?.Items?.length) && (
|
||||||
{person.data.Items?.map((item) => (
|
<CardScroller title="People" displayCards={7} disableDecoration>
|
||||||
|
{person.data?.Items?.map((item) => (
|
||||||
<Card
|
<Card
|
||||||
key={item.Id}
|
key={item.Id}
|
||||||
item={item}
|
item={item}
|
||||||
@@ -367,13 +359,13 @@ function SearchPage() {
|
|||||||
book.isSuccess &&
|
book.isSuccess &&
|
||||||
musicArtists.isSuccess &&
|
musicArtists.isSuccess &&
|
||||||
person.isSuccess &&
|
person.isSuccess &&
|
||||||
movies.data.Items?.length === 0 &&
|
movies.data?.Items?.length === 0 &&
|
||||||
series.data.Items?.length === 0 &&
|
series.data?.Items?.length === 0 &&
|
||||||
audio.data.Items?.length === 0 &&
|
audio.data?.Items?.length === 0 &&
|
||||||
musicAlbum.data.Items?.length === 0 &&
|
musicAlbum.data?.Items?.length === 0 &&
|
||||||
book.data.Items?.length === 0 &&
|
book.data?.Items?.length === 0 &&
|
||||||
musicArtists.data.Items?.length === 0 &&
|
musicArtists.data?.Items?.length === 0 &&
|
||||||
person.data.Items?.length === 0 &&
|
person.data?.Items?.length === 0 &&
|
||||||
episodes.data?.SearchHints?.length === 0 && (
|
episodes.data?.SearchHints?.length === 0 && (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ function SeriesTitlePage() {
|
|||||||
|
|
||||||
const [currentSeason, setCurrentSeason] = useState(() => {
|
const [currentSeason, setCurrentSeason] = useState(() => {
|
||||||
const result = sessionStorage.getItem(`season-${item.data?.Id}`);
|
const result = sessionStorage.getItem(`season-${item.data?.Id}`);
|
||||||
return result ?? seasons.data?.Items?.[0].IndexNumber ?? 0;
|
return result ?? 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
const currentSeasonItem = useQuery({
|
const currentSeasonItem = useQuery({
|
||||||
|
|||||||
Reference in new issue
Block a user