mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-05-22 14:56:38 +01:00
feat(tvos): Add TopShelf Extension (#1561)
This commit is contained in:
33
app/topshelf/item.tsx
Normal file
33
app/topshelf/item.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
import { useLocalSearchParams, useRootNavigationState } from "expo-router";
|
||||
import { useEffect } from "react";
|
||||
import { View } from "react-native";
|
||||
import useRouter from "@/hooks/useAppRouter";
|
||||
|
||||
export default function TopShelfItemRedirect() {
|
||||
const router = useRouter();
|
||||
const rootNavigationState = useRootNavigationState();
|
||||
const { id, type } = useLocalSearchParams<{
|
||||
id?: string;
|
||||
type?: string;
|
||||
}>();
|
||||
|
||||
useEffect(() => {
|
||||
if (!rootNavigationState?.key) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!id) {
|
||||
router.replace("/(auth)/(tabs)/(home)");
|
||||
return;
|
||||
}
|
||||
|
||||
if (type === "Series") {
|
||||
router.replace(`/(auth)/(tabs)/(home)/series/${id}`);
|
||||
return;
|
||||
}
|
||||
|
||||
router.replace(`/(auth)/(tabs)/(home)/items/page?id=${id}`);
|
||||
}, [id, rootNavigationState?.key, router, type]);
|
||||
|
||||
return <View style={{ flex: 1, backgroundColor: "#000" }} />;
|
||||
}
|
||||
32
app/topshelf/play.tsx
Normal file
32
app/topshelf/play.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { useLocalSearchParams, useRootNavigationState } from "expo-router";
|
||||
import { useEffect } from "react";
|
||||
import { View } from "react-native";
|
||||
import useRouter from "@/hooks/useAppRouter";
|
||||
|
||||
export default function TopShelfPlayRedirect() {
|
||||
const router = useRouter();
|
||||
const rootNavigationState = useRootNavigationState();
|
||||
const { id } = useLocalSearchParams<{
|
||||
id?: string;
|
||||
}>();
|
||||
|
||||
useEffect(() => {
|
||||
if (!rootNavigationState?.key) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!id) {
|
||||
router.replace("/(auth)/(tabs)/(home)");
|
||||
return;
|
||||
}
|
||||
|
||||
const queryParams = new URLSearchParams({
|
||||
itemId: id,
|
||||
offline: "false",
|
||||
});
|
||||
|
||||
router.replace(`/player/direct-player?${queryParams.toString()}`);
|
||||
}, [id, rootNavigationState?.key, router]);
|
||||
|
||||
return <View style={{ flex: 1, backgroundColor: "#000" }} />;
|
||||
}
|
||||
Reference in New Issue
Block a user