import { useDevice } from "@core/stores/deviceStore.ts"; import { create } from "@bufbuild/protobuf"; import { Button } from "@components/UI/Button.tsx"; import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@components/UI/Dialog.tsx"; import { Input } from "@components/UI/Input.tsx"; import { Label } from "@components/UI/Label.tsx"; import { Protobuf } from "@meshtastic/core"; import { useForm } from "react-hook-form"; export interface User { longName: string; shortName: string; } export interface DeviceNameDialogProps { open: boolean; onOpenChange: (open: boolean) => void; } export const DeviceNameDialog = ({ open, onOpenChange, }: DeviceNameDialogProps) => { const { hardware, nodes, connection } = useDevice(); const myNode = nodes.get(hardware.myNodeNum); const { register, handleSubmit } = useForm({ values: { longName: myNode?.user?.longName ?? "Unknown", shortName: myNode?.user?.shortName ?? "Unknown", }, }); const onSubmit = handleSubmit((data) => { connection?.setOwner( create(Protobuf.Mesh.UserSchema, { ...myNode?.user, ...data, }), ); onOpenChange(false); }); return ( Change Device Name The Device will restart once the config is saved.
); };