import { ScreenOrientationEnum, useSettings } from "@/utils/atoms/settings"; import { BACKGROUND_FETCH_TASK, registerBackgroundFetchAsync, unregisterBackgroundFetchAsync, } from "@/utils/background-tasks"; import { Ionicons } from "@expo/vector-icons"; import * as BackgroundFetch from "expo-background-fetch"; import * as ScreenOrientation from "expo-screen-orientation"; import * as TaskManager from "expo-task-manager"; import React, { useEffect } from "react"; import { Linking, Switch, TouchableOpacity, ViewProps } from "react-native"; import { toast } from "sonner-native"; import * as DropdownMenu from "zeego/dropdown-menu"; import { Text } from "../common/Text"; import { ListGroup } from "../list/ListGroup"; import { ListItem } from "../list/ListItem"; interface Props extends ViewProps {} export const OtherSettings: React.FC = () => { const [settings, updateSettings] = useSettings(); /******************** * Background task *******************/ const checkStatusAsync = async () => { await BackgroundFetch.getStatusAsync(); return await TaskManager.isTaskRegisteredAsync(BACKGROUND_FETCH_TASK); }; useEffect(() => { (async () => { const registered = await checkStatusAsync(); if (settings?.autoDownload === true && !registered) { registerBackgroundFetchAsync(); toast.success("Background downloads enabled"); } else if (settings?.autoDownload === false && registered) { unregisterBackgroundFetchAsync(); toast.info("Background downloads disabled"); } else if (settings?.autoDownload === true && registered) { // Don't to anything } else if (settings?.autoDownload === false && !registered) { // Don't to anything } else { updateSettings({ autoDownload: false }); } })(); }, [settings?.autoDownload]); /********************** *********************/ if (!settings) return null; return ( updateSettings({ autoRotate: value })} /> {ScreenOrientationEnum[settings.defaultVideoOrientation]} Orientation { updateSettings({ defaultVideoOrientation: ScreenOrientation.OrientationLock.DEFAULT, }); }} > { ScreenOrientationEnum[ ScreenOrientation.OrientationLock.DEFAULT ] } { updateSettings({ defaultVideoOrientation: ScreenOrientation.OrientationLock.PORTRAIT_UP, }); }} > { ScreenOrientationEnum[ ScreenOrientation.OrientationLock.PORTRAIT_UP ] } { updateSettings({ defaultVideoOrientation: ScreenOrientation.OrientationLock.LANDSCAPE_LEFT, }); }} > { ScreenOrientationEnum[ ScreenOrientation.OrientationLock.LANDSCAPE_LEFT ] } { updateSettings({ defaultVideoOrientation: ScreenOrientation.OrientationLock.LANDSCAPE_RIGHT, }); }} > { ScreenOrientationEnum[ ScreenOrientation.OrientationLock.LANDSCAPE_RIGHT ] } updateSettings({ safeAreaInControlsEnabled: value }) } /> Linking.openURL( "https://jellyfin.org/docs/general/clients/web-config/#custom-menu-links" ) } > updateSettings({ showCustomMenuLinks: value }) } /> ); };