Start adding search page #34
This commit is contained in:
9 files changed
+815
-17
No files matched your search
Generated
+6
-6
@@ -79,10 +79,10 @@ dependencies:
|
|||||||
version: 1.1.0(react-dom@18.2.0)(react@18.2.0)
|
version: 1.1.0(react-dom@18.2.0)(react@18.2.0)
|
||||||
tauri-plugin-log-api:
|
tauri-plugin-log-api:
|
||||||
specifier: github:tauri-apps/tauri-plugin-log#v1
|
specifier: github:tauri-apps/tauri-plugin-log#v1
|
||||||
version: github.com/tauri-apps/tauri-plugin-log/9075595196d5a66f8f3265d2aaf7e2ffeb4cb2ab
|
version: github.com/tauri-apps/tauri-plugin-log/6f56109458b09942bfc6442d32ad8637c4e6a314
|
||||||
tauri-plugin-store-api:
|
tauri-plugin-store-api:
|
||||||
specifier: github:tauri-apps/tauri-plugin-store
|
specifier: github:tauri-apps/tauri-plugin-store
|
||||||
version: github.com/tauri-apps/tauri-plugin-store/a65ce9bfb168a9a3cd7ed4102b9f22770cc3abfa
|
version: github.com/tauri-apps/tauri-plugin-store/66e06b7830037fdae0b42b5499e23334eaf4e017
|
||||||
uuid:
|
uuid:
|
||||||
specifier: ^9.0.1
|
specifier: ^9.0.1
|
||||||
version: 9.0.1
|
version: 9.0.1
|
||||||
@@ -2315,16 +2315,16 @@ packages:
|
|||||||
use-sync-external-store: 1.2.0(react@18.2.0)
|
use-sync-external-store: 1.2.0(react@18.2.0)
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
github.com/tauri-apps/tauri-plugin-log/9075595196d5a66f8f3265d2aaf7e2ffeb4cb2ab:
|
github.com/tauri-apps/tauri-plugin-log/6f56109458b09942bfc6442d32ad8637c4e6a314:
|
||||||
resolution: {tarball: https://codeload.github.com/tauri-apps/tauri-plugin-log/tar.gz/9075595196d5a66f8f3265d2aaf7e2ffeb4cb2ab}
|
resolution: {tarball: https://codeload.github.com/tauri-apps/tauri-plugin-log/tar.gz/6f56109458b09942bfc6442d32ad8637c4e6a314}
|
||||||
name: tauri-plugin-log-api
|
name: tauri-plugin-log-api
|
||||||
version: 0.0.0
|
version: 0.0.0
|
||||||
dependencies:
|
dependencies:
|
||||||
'@tauri-apps/api': 1.4.0
|
'@tauri-apps/api': 1.4.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
github.com/tauri-apps/tauri-plugin-store/a65ce9bfb168a9a3cd7ed4102b9f22770cc3abfa:
|
github.com/tauri-apps/tauri-plugin-store/66e06b7830037fdae0b42b5499e23334eaf4e017:
|
||||||
resolution: {tarball: https://codeload.github.com/tauri-apps/tauri-plugin-store/tar.gz/a65ce9bfb168a9a3cd7ed4102b9f22770cc3abfa}
|
resolution: {tarball: https://codeload.github.com/tauri-apps/tauri-plugin-store/tar.gz/66e06b7830037fdae0b42b5499e23334eaf4e017}
|
||||||
name: tauri-plugin-store-api
|
name: tauri-plugin-store-api
|
||||||
version: 0.0.0
|
version: 0.0.0
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|||||||
+8
-3
@@ -45,9 +45,10 @@ import { UserLogin, LoginWithImage, UserLoginManual } from "./routes/login";
|
|||||||
import LibraryView from "./routes/library";
|
import LibraryView from "./routes/library";
|
||||||
import ItemDetail from "./routes/item";
|
import ItemDetail from "./routes/item";
|
||||||
import SeriesTitlePage from "./routes/series/index.jsx";
|
import SeriesTitlePage from "./routes/series/index.jsx";
|
||||||
import FavouritePage from "./routes/favourite/index.jsx";
|
import FavoritePage from "./routes/favorite/index.jsx";
|
||||||
import Settings from "./routes/settings";
|
import Settings from "./routes/settings";
|
||||||
import About from "./routes/about";
|
import About from "./routes/about";
|
||||||
|
import SearchPage from "./routes/search";
|
||||||
|
|
||||||
import { VideoPlayer } from "./routes/player/videoPlayer.jsx";
|
import { VideoPlayer } from "./routes/player/videoPlayer.jsx";
|
||||||
|
|
||||||
@@ -546,8 +547,12 @@ function App() {
|
|||||||
element={<SeriesTitlePage />}
|
element={<SeriesTitlePage />}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="/favourite"
|
path="/search"
|
||||||
element={<FavouritePage />}
|
element={<SearchPage />}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="/favorite"
|
||||||
|
element={<FavoritePage />}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
path="/settings"
|
path="/settings"
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ export const AppBar = () => {
|
|||||||
</IconButton>
|
</IconButton>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ display: "flex", gap: "1.2em" }}>
|
<div style={{ display: "flex", gap: "1.2em" }}>
|
||||||
<IconButton disabled>
|
<IconButton onClick={() => navigate("/search")}>
|
||||||
<MdiMagnify />
|
<MdiMagnify />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<IconButton disabled>
|
<IconButton disabled>
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
/** @format */
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
/** @format */
|
||||||
|
|
||||||
|
const FavoritePage = () => {
|
||||||
|
<></>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default FavoritePage;
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
/** @format */
|
|
||||||
|
|
||||||
const FavouritePage = () => {
|
|
||||||
return <></>;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default FavouritePage;
|
|
||||||
@@ -0,0 +1,739 @@
|
|||||||
|
/** @format */
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
|
import TextField from "@mui/material/TextField";
|
||||||
|
import LinearProgress from "@mui/material/LinearProgress";
|
||||||
|
|
||||||
|
import { useBackdropStore } from "../../utils/store/backdrop";
|
||||||
|
|
||||||
|
import { MdiMagnify } from "../../components/icons/mdiMagnify";
|
||||||
|
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
|
||||||
|
import { getUserApi } from "@jellyfin/sdk/lib/utils/api/user-api";
|
||||||
|
import { getSearchApi } from "@jellyfin/sdk/lib/utils/api/search-api";
|
||||||
|
|
||||||
|
import useDebounce from "../../utils/hooks/useDebounce";
|
||||||
|
|
||||||
|
import "./search.module.scss";
|
||||||
|
import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api";
|
||||||
|
import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client";
|
||||||
|
import { CardScroller } from "../../components/cardScroller/cardScroller";
|
||||||
|
import { Card } from "../../components/card/card";
|
||||||
|
|
||||||
|
const SearchPage = () => {
|
||||||
|
const [searchTerm, setSearchTerm] = useState("");
|
||||||
|
const searchParam = useDebounce(searchTerm, 500);
|
||||||
|
|
||||||
|
const user = useQuery({
|
||||||
|
queryKey: ["user"],
|
||||||
|
queryFn: async () => {
|
||||||
|
let usr = await getUserApi(window.api).getCurrentUser();
|
||||||
|
return usr.data;
|
||||||
|
},
|
||||||
|
networkMode: "always",
|
||||||
|
});
|
||||||
|
|
||||||
|
const items = useQuery({
|
||||||
|
queryKey: ["search", "items", searchParam],
|
||||||
|
queryFn: async () => {
|
||||||
|
const result = await getItemsApi(window.api).getItemsByUserId({
|
||||||
|
userId: user.data.Id,
|
||||||
|
searchTerm: searchTerm,
|
||||||
|
includeItemTypes: [
|
||||||
|
BaseItemKind.Movie,
|
||||||
|
BaseItemKind.Series,
|
||||||
|
BaseItemKind.Audio,
|
||||||
|
BaseItemKind.MusicAlbum,
|
||||||
|
BaseItemKind.Book,
|
||||||
|
BaseItemKind.MusicArtist,
|
||||||
|
BaseItemKind.Person,
|
||||||
|
],
|
||||||
|
recursive: true,
|
||||||
|
});
|
||||||
|
return result.data;
|
||||||
|
},
|
||||||
|
enabled: user.isSuccess,
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {import("@jellyfin/sdk/lib/generated-client/models").BaseItemDto} BaseItemDto
|
||||||
|
* @type {[BaseItemDto[], Function]}
|
||||||
|
*/
|
||||||
|
const [movies, setMovies] = useState([]);
|
||||||
|
const [series, setSeries] = useState([]);
|
||||||
|
const [audios, setAudios] = useState([]);
|
||||||
|
const [musicAlbum, setMusicAlbum] = useState([]);
|
||||||
|
const [books, setBooks] = useState([]);
|
||||||
|
const [musicArtists, setMusicArtists] = useState([]);
|
||||||
|
const [persons, setPersons] = useState([]);
|
||||||
|
|
||||||
|
const itemLimit = 16;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (items.isSuccess) {
|
||||||
|
setMovies(
|
||||||
|
items.data.Items.filter(
|
||||||
|
(item) => item.Type == BaseItemKind.Movie,
|
||||||
|
).slice(0, itemLimit),
|
||||||
|
);
|
||||||
|
setSeries(
|
||||||
|
items.data.Items.filter(
|
||||||
|
(item) => item.Type == BaseItemKind.Series,
|
||||||
|
).slice(0, itemLimit),
|
||||||
|
);
|
||||||
|
setAudios(
|
||||||
|
items.data.Items.filter(
|
||||||
|
(item) => item.Type == BaseItemKind.Audio,
|
||||||
|
).slice(0, itemLimit),
|
||||||
|
);
|
||||||
|
setMusicAlbum(
|
||||||
|
items.data.Items.filter(
|
||||||
|
(item) => item.Type == BaseItemKind.MusicAlbum,
|
||||||
|
).slice(0, itemLimit),
|
||||||
|
);
|
||||||
|
setBooks(
|
||||||
|
items.data.Items.filter(
|
||||||
|
(item) => item.Type == BaseItemKind.Book,
|
||||||
|
).slice(0, itemLimit),
|
||||||
|
);
|
||||||
|
setMusicArtists(
|
||||||
|
items.data.Items.filter(
|
||||||
|
(item) => item.Type == BaseItemKind.MusicArtist,
|
||||||
|
).slice(0, itemLimit),
|
||||||
|
);
|
||||||
|
setPersons(
|
||||||
|
items.data.Items.filter(
|
||||||
|
(item) => item.Type == BaseItemKind.Person,
|
||||||
|
).slice(0, itemLimit),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}, [items.isSuccess]);
|
||||||
|
|
||||||
|
const [setBackdrop] = useBackdropStore((state) => [state.setBackdrop]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// Removing app's backdrop
|
||||||
|
setBackdrop("", "");
|
||||||
|
}, []);
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="scrollY"
|
||||||
|
style={{
|
||||||
|
paddingTop: "4.2em",
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
gap: "0.5em",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div className="search-header">
|
||||||
|
<TextField
|
||||||
|
variant="outlined"
|
||||||
|
style={{
|
||||||
|
width: "50%",
|
||||||
|
}}
|
||||||
|
placeholder="Search"
|
||||||
|
hiddenLabel
|
||||||
|
className="search-searchbar"
|
||||||
|
inputProps={{
|
||||||
|
className: "search-searchbar-input",
|
||||||
|
}}
|
||||||
|
value={searchTerm}
|
||||||
|
onChange={(e) => setSearchTerm(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{items.isLoading ? (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
height: "calc(100vh - 9em)",
|
||||||
|
display: "flex",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<LinearProgress
|
||||||
|
style={{
|
||||||
|
width: "25%",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
height: "100%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{movies.length > 0 && (
|
||||||
|
<CardScroller
|
||||||
|
title="Movies"
|
||||||
|
displayCards={8}
|
||||||
|
disableDecoration
|
||||||
|
>
|
||||||
|
{movies.map((item, index) => (
|
||||||
|
<Card
|
||||||
|
item={item}
|
||||||
|
seriesId={item.SeriesId}
|
||||||
|
cardTitle={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Episode
|
||||||
|
? item.SeriesName
|
||||||
|
: item.Name
|
||||||
|
}
|
||||||
|
imageType={"Primary"}
|
||||||
|
cardCaption={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Episode
|
||||||
|
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||||
|
: item.Type ==
|
||||||
|
BaseItemKind.Series
|
||||||
|
? `${
|
||||||
|
item.ProductionYear
|
||||||
|
} - ${
|
||||||
|
!!item.EndDate
|
||||||
|
? new Date(
|
||||||
|
item.EndDate,
|
||||||
|
).toLocaleString(
|
||||||
|
[],
|
||||||
|
{
|
||||||
|
year: "numeric",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: "Present"
|
||||||
|
}`
|
||||||
|
: item.ProductionYear
|
||||||
|
}
|
||||||
|
disableOverlay={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Person ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Genre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.MusicGenre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Studio
|
||||||
|
}
|
||||||
|
cardType={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.MusicAlbum ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Audio ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Genre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.MusicGenre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Studio ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Playlist
|
||||||
|
? "square"
|
||||||
|
: "portrait"
|
||||||
|
}
|
||||||
|
queryKey={[]}
|
||||||
|
userId={user.data.Id}
|
||||||
|
imageBlurhash={
|
||||||
|
!!item.ImageBlurHashes
|
||||||
|
?.Primary &&
|
||||||
|
item.ImageBlurHashes?.Primary[
|
||||||
|
Object.keys(
|
||||||
|
item.ImageBlurHashes
|
||||||
|
.Primary,
|
||||||
|
)[0]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</CardScroller>
|
||||||
|
)}
|
||||||
|
{series.length > 0 && (
|
||||||
|
<CardScroller
|
||||||
|
title="TV Shows"
|
||||||
|
displayCards={8}
|
||||||
|
disableDecoration
|
||||||
|
>
|
||||||
|
{series.map((item, index) => (
|
||||||
|
<Card
|
||||||
|
item={item}
|
||||||
|
seriesId={item.SeriesId}
|
||||||
|
cardTitle={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Episode
|
||||||
|
? item.SeriesName
|
||||||
|
: item.Name
|
||||||
|
}
|
||||||
|
imageType={"Primary"}
|
||||||
|
cardCaption={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Episode
|
||||||
|
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||||
|
: item.Type ==
|
||||||
|
BaseItemKind.Series
|
||||||
|
? `${
|
||||||
|
item.ProductionYear
|
||||||
|
} - ${
|
||||||
|
!!item.EndDate
|
||||||
|
? new Date(
|
||||||
|
item.EndDate,
|
||||||
|
).toLocaleString(
|
||||||
|
[],
|
||||||
|
{
|
||||||
|
year: "numeric",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: "Present"
|
||||||
|
}`
|
||||||
|
: item.ProductionYear
|
||||||
|
}
|
||||||
|
disableOverlay={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Person ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Genre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.MusicGenre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Studio
|
||||||
|
}
|
||||||
|
cardType={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.MusicAlbum ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Audio ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Genre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.MusicGenre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Studio ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Playlist
|
||||||
|
? "square"
|
||||||
|
: "portrait"
|
||||||
|
}
|
||||||
|
queryKey={[]}
|
||||||
|
userId={user.data.Id}
|
||||||
|
imageBlurhash={
|
||||||
|
!!item.ImageBlurHashes
|
||||||
|
?.Primary &&
|
||||||
|
item.ImageBlurHashes?.Primary[
|
||||||
|
Object.keys(
|
||||||
|
item.ImageBlurHashes
|
||||||
|
.Primary,
|
||||||
|
)[0]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</CardScroller>
|
||||||
|
)}
|
||||||
|
{audios.length > 0 && (
|
||||||
|
<CardScroller
|
||||||
|
title="Audio"
|
||||||
|
displayCards={8}
|
||||||
|
disableDecoration
|
||||||
|
>
|
||||||
|
{audios.map((item, index) => (
|
||||||
|
<Card
|
||||||
|
item={item}
|
||||||
|
seriesId={item.SeriesId}
|
||||||
|
cardTitle={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Episode
|
||||||
|
? item.SeriesName
|
||||||
|
: item.Name
|
||||||
|
}
|
||||||
|
imageType={"Primary"}
|
||||||
|
cardCaption={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Episode
|
||||||
|
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||||
|
: item.Type ==
|
||||||
|
BaseItemKind.Series
|
||||||
|
? `${
|
||||||
|
item.ProductionYear
|
||||||
|
} - ${
|
||||||
|
!!item.EndDate
|
||||||
|
? new Date(
|
||||||
|
item.EndDate,
|
||||||
|
).toLocaleString(
|
||||||
|
[],
|
||||||
|
{
|
||||||
|
year: "numeric",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: "Present"
|
||||||
|
}`
|
||||||
|
: item.ProductionYear
|
||||||
|
}
|
||||||
|
disableOverlay={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Person ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Genre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.MusicGenre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Studio
|
||||||
|
}
|
||||||
|
cardType={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.MusicAlbum ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Audio ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Genre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.MusicGenre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Studio ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Playlist
|
||||||
|
? "square"
|
||||||
|
: "portrait"
|
||||||
|
}
|
||||||
|
queryKey={[]}
|
||||||
|
userId={user.data.Id}
|
||||||
|
imageBlurhash={
|
||||||
|
!!item.ImageBlurHashes
|
||||||
|
?.Primary &&
|
||||||
|
item.ImageBlurHashes?.Primary[
|
||||||
|
Object.keys(
|
||||||
|
item.ImageBlurHashes
|
||||||
|
.Primary,
|
||||||
|
)[0]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</CardScroller>
|
||||||
|
)}
|
||||||
|
{musicAlbum.length > 0 && (
|
||||||
|
<CardScroller
|
||||||
|
title="Albums"
|
||||||
|
displayCards={8}
|
||||||
|
disableDecoration
|
||||||
|
>
|
||||||
|
{musicAlbum.map((item, index) => (
|
||||||
|
<Card
|
||||||
|
item={item}
|
||||||
|
seriesId={item.SeriesId}
|
||||||
|
cardTitle={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Episode
|
||||||
|
? item.SeriesName
|
||||||
|
: item.Name
|
||||||
|
}
|
||||||
|
imageType={"Primary"}
|
||||||
|
cardCaption={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Episode
|
||||||
|
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||||
|
: item.Type ==
|
||||||
|
BaseItemKind.Series
|
||||||
|
? `${
|
||||||
|
item.ProductionYear
|
||||||
|
} - ${
|
||||||
|
!!item.EndDate
|
||||||
|
? new Date(
|
||||||
|
item.EndDate,
|
||||||
|
).toLocaleString(
|
||||||
|
[],
|
||||||
|
{
|
||||||
|
year: "numeric",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: "Present"
|
||||||
|
}`
|
||||||
|
: item.ProductionYear
|
||||||
|
}
|
||||||
|
disableOverlay={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Person ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Genre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.MusicGenre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Studio
|
||||||
|
}
|
||||||
|
cardType={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.MusicAlbum ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Audio ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Genre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.MusicGenre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Studio ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Playlist
|
||||||
|
? "square"
|
||||||
|
: "portrait"
|
||||||
|
}
|
||||||
|
queryKey={[]}
|
||||||
|
userId={user.data.Id}
|
||||||
|
imageBlurhash={
|
||||||
|
!!item.ImageBlurHashes
|
||||||
|
?.Primary &&
|
||||||
|
item.ImageBlurHashes?.Primary[
|
||||||
|
Object.keys(
|
||||||
|
item.ImageBlurHashes
|
||||||
|
.Primary,
|
||||||
|
)[0]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</CardScroller>
|
||||||
|
)}
|
||||||
|
{books.length > 0 && (
|
||||||
|
<CardScroller
|
||||||
|
title="Books"
|
||||||
|
displayCards={8}
|
||||||
|
disableDecoration
|
||||||
|
>
|
||||||
|
{books.map((item, index) => (
|
||||||
|
<Card
|
||||||
|
item={item}
|
||||||
|
seriesId={item.SeriesId}
|
||||||
|
cardTitle={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Episode
|
||||||
|
? item.SeriesName
|
||||||
|
: item.Name
|
||||||
|
}
|
||||||
|
imageType={"Primary"}
|
||||||
|
cardCaption={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Episode
|
||||||
|
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||||
|
: item.Type ==
|
||||||
|
BaseItemKind.Series
|
||||||
|
? `${
|
||||||
|
item.ProductionYear
|
||||||
|
} - ${
|
||||||
|
!!item.EndDate
|
||||||
|
? new Date(
|
||||||
|
item.EndDate,
|
||||||
|
).toLocaleString(
|
||||||
|
[],
|
||||||
|
{
|
||||||
|
year: "numeric",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: "Present"
|
||||||
|
}`
|
||||||
|
: item.ProductionYear
|
||||||
|
}
|
||||||
|
disableOverlay={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Person ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Genre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.MusicGenre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Studio
|
||||||
|
}
|
||||||
|
cardType={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.MusicAlbum ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Audio ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Genre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.MusicGenre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Studio ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Playlist
|
||||||
|
? "square"
|
||||||
|
: "portrait"
|
||||||
|
}
|
||||||
|
queryKey={[]}
|
||||||
|
userId={user.data.Id}
|
||||||
|
imageBlurhash={
|
||||||
|
!!item.ImageBlurHashes
|
||||||
|
?.Primary &&
|
||||||
|
item.ImageBlurHashes?.Primary[
|
||||||
|
Object.keys(
|
||||||
|
item.ImageBlurHashes
|
||||||
|
.Primary,
|
||||||
|
)[0]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</CardScroller>
|
||||||
|
)}
|
||||||
|
{musicArtists.length > 0 && (
|
||||||
|
<CardScroller
|
||||||
|
title="Artists"
|
||||||
|
displayCards={8}
|
||||||
|
disableDecoration
|
||||||
|
>
|
||||||
|
{musicArtists.map((item, index) => (
|
||||||
|
<Card
|
||||||
|
item={item}
|
||||||
|
seriesId={item.SeriesId}
|
||||||
|
cardTitle={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Episode
|
||||||
|
? item.SeriesName
|
||||||
|
: item.Name
|
||||||
|
}
|
||||||
|
imageType={"Primary"}
|
||||||
|
cardCaption={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Episode
|
||||||
|
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||||
|
: item.Type ==
|
||||||
|
BaseItemKind.Series
|
||||||
|
? `${
|
||||||
|
item.ProductionYear
|
||||||
|
} - ${
|
||||||
|
!!item.EndDate
|
||||||
|
? new Date(
|
||||||
|
item.EndDate,
|
||||||
|
).toLocaleString(
|
||||||
|
[],
|
||||||
|
{
|
||||||
|
year: "numeric",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: "Present"
|
||||||
|
}`
|
||||||
|
: item.ProductionYear
|
||||||
|
}
|
||||||
|
disableOverlay={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Person ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Genre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.MusicGenre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Studio
|
||||||
|
}
|
||||||
|
cardType={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.MusicAlbum ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Audio ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Genre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.MusicGenre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Studio ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Playlist
|
||||||
|
? "square"
|
||||||
|
: "portrait"
|
||||||
|
}
|
||||||
|
queryKey={[]}
|
||||||
|
userId={user.data.Id}
|
||||||
|
imageBlurhash={
|
||||||
|
!!item.ImageBlurHashes
|
||||||
|
?.Primary &&
|
||||||
|
item.ImageBlurHashes?.Primary[
|
||||||
|
Object.keys(
|
||||||
|
item.ImageBlurHashes
|
||||||
|
.Primary,
|
||||||
|
)[0]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</CardScroller>
|
||||||
|
)}
|
||||||
|
{persons.length > 0 && (
|
||||||
|
<CardScroller
|
||||||
|
title="People"
|
||||||
|
displayCards={8}
|
||||||
|
disableDecoration
|
||||||
|
>
|
||||||
|
{persons.map((item, index) => (
|
||||||
|
<Card
|
||||||
|
item={item}
|
||||||
|
seriesId={item.SeriesId}
|
||||||
|
cardTitle={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Episode
|
||||||
|
? item.SeriesName
|
||||||
|
: item.Name
|
||||||
|
}
|
||||||
|
imageType={"Primary"}
|
||||||
|
cardCaption={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Episode
|
||||||
|
? `S${item.ParentIndexNumber}:E${item.IndexNumber} - ${item.Name}`
|
||||||
|
: item.Type ==
|
||||||
|
BaseItemKind.Series
|
||||||
|
? `${
|
||||||
|
item.ProductionYear
|
||||||
|
} - ${
|
||||||
|
!!item.EndDate
|
||||||
|
? new Date(
|
||||||
|
item.EndDate,
|
||||||
|
).toLocaleString(
|
||||||
|
[],
|
||||||
|
{
|
||||||
|
year: "numeric",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
: "Present"
|
||||||
|
}`
|
||||||
|
: item.ProductionYear
|
||||||
|
}
|
||||||
|
disableOverlay={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Person ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Genre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.MusicGenre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Studio
|
||||||
|
}
|
||||||
|
cardType={
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.MusicAlbum ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Audio ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Genre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.MusicGenre ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Studio ||
|
||||||
|
item.Type ==
|
||||||
|
BaseItemKind.Playlist
|
||||||
|
? "square"
|
||||||
|
: "portrait"
|
||||||
|
}
|
||||||
|
queryKey={[]}
|
||||||
|
userId={user.data.Id}
|
||||||
|
imageBlurhash={
|
||||||
|
!!item.ImageBlurHashes
|
||||||
|
?.Primary &&
|
||||||
|
item.ImageBlurHashes?.Primary[
|
||||||
|
Object.keys(
|
||||||
|
item.ImageBlurHashes
|
||||||
|
.Primary,
|
||||||
|
)[0]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</CardScroller>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SearchPage;
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
/** @format */
|
||||||
|
|
||||||
|
.search {
|
||||||
|
&-header {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 1em;
|
||||||
|
height: 4em;
|
||||||
|
}
|
||||||
|
&-searchbar {
|
||||||
|
border-radius: 100px !important;
|
||||||
|
background: rgb(255 255 255 / 0.09);
|
||||||
|
border: none !important;
|
||||||
|
.MuiInputBase-root.MuiOutlinedInput-root.MuiInputBase-colorPrimary.MuiInputBase-formControl.MuiInputBase-hiddenLabel.css-187yyed-MuiInputBase-root-MuiOutlinedInput-root {
|
||||||
|
border-radius: 100px !important;
|
||||||
|
}
|
||||||
|
&-input {
|
||||||
|
text-align: center;
|
||||||
|
padding: 0.75em 1.5em !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
/** @format */
|
||||||
|
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
|
// see https://github.com/tannerlinsley/react-query/issues/293
|
||||||
|
// see https://usehooks.com/useDebounce/
|
||||||
|
export default function useDebounce(value, delay) {
|
||||||
|
// State and setters for debounced value
|
||||||
|
const [debouncedValue, setDebouncedValue] = useState(value);
|
||||||
|
|
||||||
|
useEffect(
|
||||||
|
() => {
|
||||||
|
// Update debounced value after delay
|
||||||
|
const handler = setTimeout(() => {
|
||||||
|
setDebouncedValue(value);
|
||||||
|
}, delay);
|
||||||
|
|
||||||
|
// Cancel the timeout if value changes (also on delay change or unmount)
|
||||||
|
// This is how we prevent debounced value from updating if value is changed ...
|
||||||
|
// .. within the delay period. Timeout gets cleared and restarted.
|
||||||
|
return () => {
|
||||||
|
clearTimeout(handler);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
[value, delay], // Only re-call effect if value or delay changes
|
||||||
|
);
|
||||||
|
|
||||||
|
return debouncedValue;
|
||||||
|
}
|
||||||
Reference in new issue
Block a user