import { Hash, MutableReference, MutableSet } from '@hyper-hyper-space/core'; import { Device, Home } from '@hyper-hyper-space/home'; import { useObjectState } from '@hyper-hyper-space/react'; import { Button, Dialog, DialogActions, DialogContent, DialogTitle, Grid, List, Stack, Typography } from '@mui/material'; import { Fragment, useState, useEffect } from 'react'; import { useNavigate, useOutletContext } from 'react-router'; import { HomeContext } from '../HomeSpace'; import ReceiveLinkOffer from './ReceiveLinkOffer'; function ManageDevicesDialog() { const navigate = useNavigate(); const close = () => { navigate('..'); } const { home, localDevice } = useOutletContext(); const homeState = useObjectState(home); let [showReceiveDialog, setShowReceiveDialog] = useState(false); const linkAnotherDevice = () => { setShowReceiveDialog(true); }; const cancelLinkAnotherDevice = () => { setShowReceiveDialog(false); } return ( Linked Devices { homeState !== undefined && homeState.value !== undefined && Array.from(((homeState?.value as Home)?.devices)?.values() as IterableIterator).map((device: Device) => ( {device &&
{device.name?.getValue()}
{/**/} {device.equals(localDevice) && This Device}
}
) ) } {/*{devicesState !== undefined && devicesState.current !== undefined && Array.from((devicesState.current as MutableSet)?.valueHashes()).map((deviceHash: Hash) => { const deviceRow = (deviceProxy?: StateProxy) => { const device = deviceProxy?.current as Device; const deviceName = deviceProxy?.fields['name']?.current as MutableReference; return ( {device &&
{deviceName?.getValue()}
{/ ** /} {device.equals(localDevice) && This Device}
}
); }; return deviceRow(devicesState.contents[deviceHash] as StateProxy) } ) }*/}
{showReceiveDialog && } {/* {Array.from(devices.value?.values()).map((device: Device) => {device.name?.getValue() || ''} )} */}
); } export default ManageDevicesDialog;