mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-06-18 20:00:25 +01:00
fix: #79
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import { Button } from "@/components/Button";
|
||||||
import { HorizontalScroll } from "@/components/common/HorrizontalScroll";
|
import { HorizontalScroll } from "@/components/common/HorrizontalScroll";
|
||||||
import { Input } from "@/components/common/Input";
|
import { Input } from "@/components/common/Input";
|
||||||
import { Text } from "@/components/common/Text";
|
import { Text } from "@/components/common/Text";
|
||||||
@@ -11,6 +12,7 @@ import SeriesPoster from "@/components/posters/SeriesPoster";
|
|||||||
import { apiAtom, userAtom } from "@/providers/JellyfinProvider";
|
import { apiAtom, userAtom } from "@/providers/JellyfinProvider";
|
||||||
import { useSettings } from "@/utils/atoms/settings";
|
import { useSettings } from "@/utils/atoms/settings";
|
||||||
import { getUserItemData } from "@/utils/jellyfin/user-library/getUserItemData";
|
import { getUserItemData } from "@/utils/jellyfin/user-library/getUserItemData";
|
||||||
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
import { Api } from "@jellyfin/sdk";
|
import { Api } from "@jellyfin/sdk";
|
||||||
import {
|
import {
|
||||||
BaseItemDto,
|
BaseItemDto,
|
||||||
@@ -19,9 +21,21 @@ import {
|
|||||||
import { getItemsApi, getSearchApi } from "@jellyfin/sdk/lib/utils/api";
|
import { getItemsApi, getSearchApi } from "@jellyfin/sdk/lib/utils/api";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { router, useNavigation } from "expo-router";
|
import {
|
||||||
|
Href,
|
||||||
|
router,
|
||||||
|
useLocalSearchParams,
|
||||||
|
useNavigation,
|
||||||
|
usePathname,
|
||||||
|
} from "expo-router";
|
||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
import React, { useCallback, useLayoutEffect, useMemo, useState } from "react";
|
import React, {
|
||||||
|
useCallback,
|
||||||
|
useEffect,
|
||||||
|
useLayoutEffect,
|
||||||
|
useMemo,
|
||||||
|
useState,
|
||||||
|
} from "react";
|
||||||
import { Platform, ScrollView, TouchableOpacity, View } from "react-native";
|
import { Platform, ScrollView, TouchableOpacity, View } from "react-native";
|
||||||
import { useDebounce } from "use-debounce";
|
import { useDebounce } from "use-debounce";
|
||||||
|
|
||||||
@@ -35,6 +49,10 @@ const exampleSearches = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export default function search() {
|
export default function search() {
|
||||||
|
const params = useLocalSearchParams();
|
||||||
|
|
||||||
|
const { q, prev } = params as { q: string; prev: Href<string> };
|
||||||
|
|
||||||
const [search, setSearch] = useState<string>("");
|
const [search, setSearch] = useState<string>("");
|
||||||
|
|
||||||
const [debouncedSearch] = useDebounce(search, 500);
|
const [debouncedSearch] = useDebounce(search, 500);
|
||||||
@@ -48,6 +66,10 @@ export default function search() {
|
|||||||
return settings?.searchEngine || "Jellyfin";
|
return settings?.searchEngine || "Jellyfin";
|
||||||
}, [settings]);
|
}, [settings]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (q && q.length > 0) setSearch(q);
|
||||||
|
}, [q]);
|
||||||
|
|
||||||
const searchFn = useCallback(
|
const searchFn = useCallback(
|
||||||
async ({
|
async ({
|
||||||
types,
|
types,
|
||||||
@@ -95,7 +117,10 @@ export default function search() {
|
|||||||
navigation.setOptions({
|
navigation.setOptions({
|
||||||
headerSearchBarOptions: {
|
headerSearchBarOptions: {
|
||||||
placeholder: "Search...",
|
placeholder: "Search...",
|
||||||
onChangeText: (e: any) => setSearch(e.nativeEvent.text),
|
onChangeText: (e: any) => {
|
||||||
|
router.setParams({ q: "" });
|
||||||
|
setSearch(e.nativeEvent.text);
|
||||||
|
},
|
||||||
hideWhenScrolling: false,
|
hideWhenScrolling: false,
|
||||||
autoFocus: true,
|
autoFocus: true,
|
||||||
},
|
},
|
||||||
@@ -196,6 +221,13 @@ export default function search() {
|
|||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
|
{!!q && (
|
||||||
|
<View className="px-4 flex flex-col space-y-2">
|
||||||
|
<Text className="text-neutral-500 ">
|
||||||
|
Results for <Text className="text-purple-600">{q}</Text>
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
<SearchItemWrapper
|
<SearchItemWrapper
|
||||||
header="Movies"
|
header="Movies"
|
||||||
ids={movies?.map((m) => m.Id!)}
|
ids={movies?.map((m) => m.Id!)}
|
||||||
|
|||||||
@@ -10,11 +10,13 @@ import Poster from "../posters/Poster";
|
|||||||
import { useAtom } from "jotai";
|
import { useAtom } from "jotai";
|
||||||
import { apiAtom } from "@/providers/JellyfinProvider";
|
import { apiAtom } from "@/providers/JellyfinProvider";
|
||||||
import { getPrimaryImageUrl } from "@/utils/jellyfin/image/getPrimaryImageUrl";
|
import { getPrimaryImageUrl } from "@/utils/jellyfin/image/getPrimaryImageUrl";
|
||||||
import { router } from "expo-router";
|
import { router, usePathname } from "expo-router";
|
||||||
|
|
||||||
export const CastAndCrew = ({ item }: { item: BaseItemDto }) => {
|
export const CastAndCrew = ({ item }: { item: BaseItemDto }) => {
|
||||||
const [api] = useAtom(apiAtom);
|
const [api] = useAtom(apiAtom);
|
||||||
|
|
||||||
|
const pathname = usePathname();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View>
|
<View>
|
||||||
<Text className="text-lg font-bold mb-2 px-4">Cast & Crew</Text>
|
<Text className="text-lg font-bold mb-2 px-4">Cast & Crew</Text>
|
||||||
@@ -23,7 +25,7 @@ export const CastAndCrew = ({ item }: { item: BaseItemDto }) => {
|
|||||||
renderItem={(item, index) => (
|
renderItem={(item, index) => (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
// TODO: Navigate to person
|
router.push(`/search?q=${item.Name}&prev=${pathname}`);
|
||||||
}}
|
}}
|
||||||
key={item.Id}
|
key={item.Id}
|
||||||
className="flex flex-col w-32"
|
className="flex flex-col w-32"
|
||||||
|
|||||||
Reference in New Issue
Block a user