mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-01-15 15:48:05 +00:00
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
49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
import type React from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { Text, View } from "react-native";
|
|
import { useJellyfinDiscovery } from "@/hooks/useJellyfinDiscovery";
|
|
import { Button } from "./Button";
|
|
import { ListGroup } from "./list/ListGroup";
|
|
import { ListItem } from "./list/ListItem";
|
|
|
|
interface Props {
|
|
onServerSelect?: (server: { address: string; serverName?: string }) => void;
|
|
}
|
|
|
|
const JellyfinServerDiscovery: React.FC<Props> = ({ onServerSelect }) => {
|
|
const { servers, isSearching, startDiscovery } = useJellyfinDiscovery();
|
|
const { t } = useTranslation();
|
|
|
|
return (
|
|
<View className='mt-2'>
|
|
<Button onPress={startDiscovery} color='black'>
|
|
<Text className='text-white text-center'>
|
|
{isSearching
|
|
? t("server.searching")
|
|
: t("server.search_for_local_servers")}
|
|
</Text>
|
|
</Button>
|
|
|
|
{servers.length ? (
|
|
<ListGroup title={t("server.servers")} className='mt-4'>
|
|
{servers.map((server) => (
|
|
<ListItem
|
|
key={server.address}
|
|
onPress={() =>
|
|
onServerSelect?.({
|
|
address: server.address,
|
|
serverName: server.serverName,
|
|
})
|
|
}
|
|
title={server.address}
|
|
showArrow
|
|
/>
|
|
))}
|
|
</ListGroup>
|
|
) : null}
|
|
</View>
|
|
);
|
|
};
|
|
|
|
export default JellyfinServerDiscovery;
|