feat(search): Add Episode to search
This commit is contained in:
4 files changed
+50
-16
No files matched your search
+2
-1
@@ -1,4 +1,5 @@
|
|||||||
- # v0.0.5-dev
|
- # v0.0.5-dev
|
||||||
> **Note** : This is an unstable release
|
> **Note** : This is an unstable release
|
||||||
- feat(web): Add new About page (#258) by @prayag17
|
- feat(web): Add new About page (#258) by @prayag17
|
||||||
- feat(web): Allow managing servers from settings dialog by @prayag17
|
- feat(web): Allow managing servers from settings dialog by @prayag17
|
||||||
|
- feat(search): Add Episode to search by @prayag17
|
||||||
@@ -120,11 +120,7 @@ export const Card = ({
|
|||||||
overrideIcon === "User"
|
overrideIcon === "User"
|
||||||
? `${api.basePath}/Users/${item.Id}/Images/Primary`
|
? `${api.basePath}/Users/${item.Id}/Images/Primary`
|
||||||
: api.getItemImageUrl(
|
: api.getItemImageUrl(
|
||||||
seriesId
|
seriesId ? item.SeriesId : item.AlbumId ?? item.Id,
|
||||||
? item.SeriesId
|
|
||||||
: item.AlbumId
|
|
||||||
? item.AlbumId
|
|
||||||
: item.Id,
|
|
||||||
imageType,
|
imageType,
|
||||||
{
|
{
|
||||||
quality: 90,
|
quality: 90,
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import PlayButton from "../buttons/playButton";
|
|||||||
* @property {string} imageBlurhash
|
* @property {string} imageBlurhash
|
||||||
* @property {Array} queryKey
|
* @property {Array} queryKey
|
||||||
* @property {string} userId
|
* @property {string} userId
|
||||||
|
* @property {boolean} disableRunTime
|
||||||
* @property {() => {}} onClick
|
* @property {() => {}} onClick
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -40,6 +41,7 @@ export const EpisodeCard = ({
|
|||||||
imageBlurhash,
|
imageBlurhash,
|
||||||
queryKey,
|
queryKey,
|
||||||
userId,
|
userId,
|
||||||
|
disableRunTime = false,
|
||||||
onClick,
|
onClick,
|
||||||
}) => {
|
}) => {
|
||||||
const [api] = useApi((state) => [state.api]);
|
const [api] = useApi((state) => [state.api]);
|
||||||
@@ -126,7 +128,7 @@ export const EpisodeCard = ({
|
|||||||
<MarkPlayedButton
|
<MarkPlayedButton
|
||||||
itemId={item.Id}
|
itemId={item.Id}
|
||||||
itemName={item.Name}
|
itemName={item.Name}
|
||||||
isPlayed={item.UserData.Played}
|
isPlayed={item.UserData?.Played}
|
||||||
queryKey={queryKey}
|
queryKey={queryKey}
|
||||||
userId={userId}
|
userId={userId}
|
||||||
/>
|
/>
|
||||||
@@ -172,15 +174,17 @@ export const EpisodeCard = ({
|
|||||||
>
|
>
|
||||||
{cardTitle}
|
{cardTitle}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography
|
{!disableRunTime && (
|
||||||
variant="subtitle1"
|
<Typography
|
||||||
fontWeight={500}
|
variant="subtitle1"
|
||||||
noWrap
|
fontWeight={500}
|
||||||
textAlign="start"
|
noWrap
|
||||||
style={{ opacity: 0.8, flexShrink: 0 }}
|
textAlign="start"
|
||||||
>
|
style={{ opacity: 0.8, flexShrink: 0 }}
|
||||||
{getRuntimeCompact(item.RunTimeTicks)}
|
>
|
||||||
</Typography>
|
{getRuntimeCompact(item.RunTimeTicks)}
|
||||||
|
</Typography>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Typography
|
<Typography
|
||||||
|
|||||||
@@ -16,7 +16,9 @@ import useDebounce from "../../utils/hooks/useDebounce";
|
|||||||
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";
|
||||||
import { getPersonsApi } from "@jellyfin/sdk/lib/utils/api/persons-api";
|
import { getPersonsApi } from "@jellyfin/sdk/lib/utils/api/persons-api";
|
||||||
|
import { getSearchApi } from "@jellyfin/sdk/lib/utils/api/search-api";
|
||||||
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 { useApi } from "../../utils/store/api";
|
import { useApi } from "../../utils/store/api";
|
||||||
import "./search.module.scss";
|
import "./search.module.scss";
|
||||||
@@ -142,6 +144,20 @@ const SearchPage = () => {
|
|||||||
enabled: user.isSuccess,
|
enabled: user.isSuccess,
|
||||||
cacheTime: 0,
|
cacheTime: 0,
|
||||||
});
|
});
|
||||||
|
const episodes = useQuery({
|
||||||
|
queryKey: ["search", "items", "Episodes", searchParam],
|
||||||
|
queryFn: async () => {
|
||||||
|
const result = await getSearchApi(api).get({
|
||||||
|
userId: user.data.Id,
|
||||||
|
searchTerm,
|
||||||
|
limit: itemLimit,
|
||||||
|
includeItemTypes: ["Episode"],
|
||||||
|
});
|
||||||
|
return result.data;
|
||||||
|
},
|
||||||
|
enabled: user.isSuccess,
|
||||||
|
cacheTime: 0,
|
||||||
|
});
|
||||||
|
|
||||||
const [setBackdrop] = useBackdropStore((state) => [state.setBackdrop]);
|
const [setBackdrop] = useBackdropStore((state) => [state.setBackdrop]);
|
||||||
|
|
||||||
@@ -269,6 +285,23 @@ const SearchPage = () => {
|
|||||||
))}
|
))}
|
||||||
</CardScroller>
|
</CardScroller>
|
||||||
)}
|
)}
|
||||||
|
{episodes.isSuccess && episodes.data.TotalRecordCount > 0 && (
|
||||||
|
<CardScroller title="Episodes" displayCards={4} disableDecoration>
|
||||||
|
{episodes.data.SearchHints.map((episode) => {
|
||||||
|
return (
|
||||||
|
<EpisodeCard
|
||||||
|
key={episode.Id}
|
||||||
|
item={episode}
|
||||||
|
cardTitle={episode.Series}
|
||||||
|
cardCaption={`S${episode.ParentIndexNumber}:E${episode.IndexNumber} - ${episode.Name}`}
|
||||||
|
queryKey={["search", "items", "Episodes", searchParam]}
|
||||||
|
userId={user.data.Id}
|
||||||
|
disableRunTime
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</CardScroller>
|
||||||
|
)}
|
||||||
{audio.isSuccess && audio.data.Items.length > 0 && (
|
{audio.isSuccess && audio.data.Items.length > 0 && (
|
||||||
<CardScroller title="Audio" displayCards={8} disableDecoration>
|
<CardScroller title="Audio" displayCards={8} disableDecoration>
|
||||||
{audio.data.Items.map((item, index) => (
|
{audio.data.Items.map((item, index) => (
|
||||||
|
|||||||
Reference in new issue
Block a user