mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-24 17:06:18 -05:00
Preserving null output status to represent unsupported device.
This commit is contained in:
parent
41e89843bf
commit
703f916c53
2 changed files with 12 additions and 5 deletions
|
|
@ -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)}
|
||||
|
|
|
|||
|
|
@ -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(() => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue