feat(settings): unify Local network + Companion server URLs via the resolver

- Local network LAN URL -> ServerUrlField + jellyfinProbe (picks http on LAN, confirms it's the Jellyfin server).

- Companion pairing: resolve the server field on blur (jellyfinProbe) + status line, keeping the existing form styling (hook, not the block field).
This commit is contained in:
Gauvain
2026-06-04 20:47:24 +02:00
parent b54b0c670b
commit fb3a994351
2 changed files with 19 additions and 6 deletions

View File

@@ -11,10 +11,13 @@ import {
View,
} from "react-native";
import { Button } from "@/components/Button";
import { ServerUrlStatusText } from "@/components/common/ServerUrlStatusText";
import { Text } from "@/components/common/Text";
import useRouter from "@/hooks/useAppRouter";
import { useServerUrlResolver } from "@/hooks/useServerUrlResolver";
import { apiAtom, userAtom } from "@/providers/JellyfinProvider";
import { sendCredentialsToTV } from "@/utils/pairingService";
import { jellyfinProbe } from "@/utils/serverUrl/probes/jellyfin";
type ScreenState =
| "scanning"
@@ -49,6 +52,7 @@ export const CompanionLoginScreen: React.FC = () => {
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
const [errorMessage, setErrorMessage] = useState<string | null>(null);
const serverResolver = useServerUrlResolver(jellyfinProbe);
// Pre-fill server URL and username from current session
useEffect(() => {
@@ -405,7 +409,16 @@ export const CompanionLoginScreen: React.FC = () => {
autoCorrect={false}
keyboardType='url'
returnKeyType='next'
onBlur={() => {
const candidate = serverUrl.trim();
if (candidate) {
serverResolver.resolve(candidate).then((r) => {
if (r.ok) setServerUrl(r.url);
});
}
}}
/>
<ServerUrlStatusText state={serverResolver} className='mt-2' />
</View>
<View className='mb-5'>

View File

@@ -12,8 +12,9 @@ import {
type LocalNetworkConfig,
updateServerLocalConfig,
} from "@/utils/secureCredentials";
import { jellyfinProbe } from "@/utils/serverUrl/probes/jellyfin";
import { Button } from "../Button";
import { Input } from "../common/Input";
import { ServerUrlField } from "../common/ServerUrlField";
import { Text } from "../common/Text";
import { ListGroup } from "../list/ListGroup";
import { ListItem } from "../list/ListItem";
@@ -162,13 +163,12 @@ export function LocalNetworkSettings(): React.ReactElement | null {
}
>
<View className=''>
<Input
placeholder={t("home.settings.network.local_url_placeholder")}
<ServerUrlField
value={config.localUrl}
onChangeText={handleLocalUrlChange}
keyboardType='url'
autoCapitalize='none'
autoCorrect={false}
onResolved={(url) => saveConfig({ ...config, localUrl: url })}
probe={jellyfinProbe}
placeholder={t("home.settings.network.local_url_placeholder")}
/>
</View>
</ListGroup>