import { Button } from "@/components/Button"; import { Text } from "@/components/common/Text"; import { ListItem } from "@/components/ListItem"; import { SettingToggles } from "@/components/settings/SettingToggles"; import { useDownload } from "@/providers/DownloadProvider"; import { apiAtom, useJellyfin, userAtom } from "@/providers/JellyfinProvider"; import { clearLogs, readFromLog } from "@/utils/log"; import { getQuickConnectApi } from "@jellyfin/sdk/lib/utils/api"; import { useQuery } from "@tanstack/react-query"; import * as Haptics from "expo-haptics"; import { useAtom } from "jotai"; import { Alert, ScrollView, View } from "react-native"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { toast } from "sonner-native"; export default function settings() { const { logout } = useJellyfin(); const { deleteAllFiles } = useDownload(); const [api] = useAtom(apiAtom); const [user] = useAtom(userAtom); const { data: logs } = useQuery({ queryKey: ["logs"], queryFn: async () => readFromLog(), refetchInterval: 1000, }); const insets = useSafeAreaInsets(); const openQuickConnectAuthCodeInput = () => { Alert.prompt( "Quick connect", "Enter the quick connect code", async (text) => { if (text) { try { const res = await getQuickConnectApi(api!).authorizeQuickConnect({ code: text, userId: user?.Id, }); console.log(res.status, res.statusText, res.data); if (res.status === 200) { Haptics.notificationAsync( Haptics.NotificationFeedbackType.Success ); Alert.alert("Success", "Quick connect authorized"); } else { Haptics.notificationAsync(Haptics.NotificationFeedbackType.Error); Alert.alert("Error", "Invalid code"); } } catch (e) { Haptics.notificationAsync(Haptics.NotificationFeedbackType.Error); Alert.alert("Error", "Invalid code"); } } } ); }; return ( Information Quick connect Tests Account and storage Logs {logs?.map((log, index) => ( {log.level} {log.message} ))} {logs?.length === 0 && ( No logs available )} ); }