Preserving null output status to represent unsupported device.

This commit is contained in:
Roland 2022-02-04 16:18:11 -07:00
parent 41e89843bf
commit 703f916c53
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
2 changed files with 12 additions and 5 deletions

View file

@ -648,8 +648,7 @@ export function CardGroupCentered(props) {
export function HotspotToggle() {
let {on, setHotspot} = useHotspot();
return <Checkbox toggle
label={on === null ?
'Toggle the WiFi Hotspot. Only supported on Raspberry Pi.' : 'Toggle WiFi Hotspot'}
label='WiFi Hotspot'
disabled={on === null}
checked={on === true}
onChange={(e, data) => setHotspot(data.checked)}

View file

@ -2,9 +2,9 @@ import {useEffect, useState} from "react";
import {
fetchDomains,
filesSearch,
getHotspotStatus,
getDownloaders,
getFiles,
getHotspotStatus,
getVersion,
killDownloads,
searchArchives,
@ -196,8 +196,16 @@ export const useHotspot = () => {
const fetchHotspotStatus = async () => {
const status = await getHotspotStatus();
// Wi-Fi can be: connected, disconnected, unavailable.
setOn(status === 'connected');
if (status === 'connected') {
// Hotspot is on.
setOn(true);
} else if (status === 'disconnected' || status === 'unavailable') {
// Hotspot can be turned on.
setOn(false);
} else {
// Hotspot is not supported. API is probably running in a Docker container.
setOn(null);
}
}
useEffect(() => {