import { keepPreviousData } from "@tanstack/react-query";
import { q } from "@thorium/context/AppContext";
import { pickStarmapShip } from "@thorium/cores/StarmapCore/pickShip";
import { useLocalStorage } from "@thorium/hooks/useLocalStorage";
import { useStation } from "@thorium/routes/station/useStation";
import Button from "@thorium/ui/Button";
import Checkbox from "@thorium/ui/Checkbox";
import { InputField, OutputField } from "@thorium/ui/Core";
import InfoTip from "@thorium/ui/InfoTip";
import Select from "@thorium/ui/Select";
import { cn } from "@thorium/utils/cn";
import { Suspense } from "react";
import { shortRangeStateMap } from "./shared";
export function ShortRangeCommCore() {
const { shipId } = useStation();
const [shortRangeComm] = q.shortRangeComm.get.useNetRequest({ shipId });
const [{ allowOtherParticipants }, setAllowOtherParticipants] = useLocalStorage(
"core-short-range-allow-other-participants",
{
allowOtherParticipants: false,
},
);
if (!shortRangeComm)
return (
No Short Range Comm
);
return (
{shortRangeStateMap[shortRangeComm.state]}
What would you like to set the frequency to?
100 - 350
>
}
onClick={(value) => {
if (Number.isNaN(Number(value))) return;
q.shortRangeComm.setFrequency.netSend({
shipId,
frequency: Math.min(350, Math.max(100, Number(value))),
});
}}
promptValue={shortRangeComm.frequency}
>
{shortRangeComm.frequency.toFixed(2)} MHz
Allow Other Participants
Allow another participant to join the conversation after it is connected.
>
}
checked={allowOtherParticipants}
onChange={(event) =>
setAllowOtherParticipants({
allowOtherParticipants: event.currentTarget.checked,
})
}
/>
{shortRangeComm.state === "idle" ? (
) : shortRangeComm.state === "hailing" && shortRangeComm.conversationId ? (
) : (
)}