From 0894fd76f507924ff681beac91d1d911ebe0a651 Mon Sep 17 00:00:00 2001 From: Sacha Weatherstone Date: Mon, 20 Feb 2023 21:07:55 +1000 Subject: [PATCH] more state changes --- src/components/Dialog/DialogManager.tsx | 1 - src/components/Dialog/ImportDialog.tsx | 1 - src/components/Dialog/QRDialog.tsx | 13 +- src/components/Form/DynamicForm.tsx | 18 +- src/components/PageComponents/Channel.tsx | 187 +++--------------- src/core/stores/deviceStore.ts | 16 +- src/pages/Channels.tsx | 11 +- src/pages/Messages.tsx | 49 ++--- .../{channelSettings.ts => channel.ts} | 19 +- src/validation/config/network.ts | 10 +- 10 files changed, 112 insertions(+), 213 deletions(-) rename src/validation/{channelSettings.ts => channel.ts} (54%) diff --git a/src/components/Dialog/DialogManager.tsx b/src/components/Dialog/DialogManager.tsx index 8576dff2..3417da8c 100644 --- a/src/components/Dialog/DialogManager.tsx +++ b/src/components/Dialog/DialogManager.tsx @@ -22,7 +22,6 @@ export const DialogManager = (): JSX.Element => { onOpenChange={(open) => { setDialogOpen("import", open); }} - channels={channels} loraConfig={config.lora} /> void; loraConfig?: Protobuf.Config_LoRaConfig; - channels: Protobuf.Channel[]; } export const ImportDialog = ({ diff --git a/src/components/Dialog/QRDialog.tsx b/src/components/Dialog/QRDialog.tsx index f26d2012..45843268 100644 --- a/src/components/Dialog/QRDialog.tsx +++ b/src/components/Dialog/QRDialog.tsx @@ -12,14 +12,14 @@ import { DialogTitle } from "@components/UI/Dialog.js"; import { ClipboardIcon } from "lucide-react"; -import { Protobuf } from "@meshtastic/meshtasticjs"; +import { Protobuf, Types } from "@meshtastic/meshtasticjs"; import { Label } from "@components/UI/Label.js"; export interface QRDialogProps { open: boolean; onOpenChange: (open: boolean) => void; loraConfig?: Protobuf.Config_LoRaConfig; - channels: Protobuf.Channel[]; + channels: Map; } export const QRDialog = ({ @@ -31,9 +31,12 @@ export const QRDialog = ({ const [selectedChannels, setSelectedChannels] = useState([0]); const [QRCodeURL, setQRCodeURL] = useState(""); + const filteredChannels = Array.from(channels.values()).filter((channel) => + selectedChannels.includes(channel.index) + ); + useEffect(() => { - const channelsToEncode = channels - .filter((channel) => selectedChannels.includes(channel.index)) + const channelsToEncode = filteredChannels .map((channel) => channel.settings) .filter((ch): ch is Protobuf.ChannelSettings => !!ch); const encoded = new Protobuf.ChannelSet( @@ -62,7 +65,7 @@ export const QRDialog = ({
- {channels.map((channel) => ( + {filteredChannels.map((channel) => (