Files
streamyfin/components/series/SeriesActions.tsx
Gauvain 5f39622ad6
Some checks failed
🤖 Android APK Build / 🏗️ Build Android APK (push) Has been cancelled
🤖 iOS IPA Build / 🏗️ Build iOS IPA (push) Has been cancelled
🔒 Lockfile Consistency Check / 🔍 Check bun.lock and package.json consistency (push) Has been cancelled
🛡️ CodeQL Analysis / 🔎 Analyze with CodeQL (javascript-typescript) (push) Has been cancelled
🏷️🔀Merge Conflict Labeler / 🏷️ Labeling Merge Conflicts (push) Has been cancelled
🕒 Handle Stale Issues / 🗑️ Cleanup Stale Issues (push) Has been cancelled
fix: bump biome and fix error (#864)
2025-07-21 09:44:24 +02:00

54 lines
1.4 KiB
TypeScript

import { Ionicons } from "@expo/vector-icons";
import type { BaseItemDto } from "@jellyfin/sdk/lib/generated-client";
import { useCallback, useMemo } from "react";
import {
Alert,
Linking,
TouchableOpacity,
View,
type ViewProps,
} from "react-native";
import type { MovieDetails } from "@/utils/jellyseerr/server/models/Movie";
import type { TvDetails } from "@/utils/jellyseerr/server/models/Tv";
interface Props extends ViewProps {
item: BaseItemDto | MovieDetails | TvDetails;
}
export const ItemActions = ({ item, ...props }: Props) => {
const trailerLink = useMemo(() => {
if ("RemoteTrailers" in item && item.RemoteTrailers?.[0]?.Url) {
return item.RemoteTrailers[0].Url;
}
if ("relatedVideos" in item) {
return item.relatedVideos?.find((v) => v.type === "Trailer")?.url;
}
return undefined;
}, [item]);
const openTrailer = useCallback(async () => {
if (!trailerLink) {
Alert.alert("No trailer available");
return;
}
try {
await Linking.openURL(trailerLink);
} catch (err) {
console.error("Failed to open trailer link:", err);
}
}, [trailerLink]);
return (
<View className='' {...props}>
{trailerLink && (
<TouchableOpacity onPress={openTrailer}>
<Ionicons name='film-outline' size={24} color='white' />
</TouchableOpacity>
)}
</View>
);
};