Browse Source

Fix QR Code

pull/43/head
Sacha Weatherstone 4 years ago
parent
commit
b2fd4e877a
  1. 11
      src/components/Dialog/QRDialog.tsx

11
src/components/Dialog/QRDialog.tsx

@ -2,7 +2,7 @@ import type React from "react";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { fromByteArray } from "base64-js"; import { fromByteArray } from "base64-js";
import toast from "react-hot-toast"; import { toast } from "react-hot-toast";
import { QRCode } from "react-qrcode-logo"; import { QRCode } from "react-qrcode-logo";
import { Dialog } from "@headlessui/react"; import { Dialog } from "@headlessui/react";
@ -26,7 +26,7 @@ export const QRDialog = ({
loraConfig, loraConfig,
channels, channels,
}: QRDialogProps): JSX.Element => { }: QRDialogProps): JSX.Element => {
const [selectedChannels, setSelectedChannels] = useState<number[]>([]); const [selectedChannels, setSelectedChannels] = useState<number[]>([0]);
const [QRCodeURL, setQRCodeURL] = useState<string>(""); const [QRCodeURL, setQRCodeURL] = useState<string>("");
useEffect(() => { useEffect(() => {
@ -45,7 +45,7 @@ export const QRDialog = ({
.replace(/\+/g, "-") .replace(/\+/g, "-")
.replace(/\//g, "_"); .replace(/\//g, "_");
setQRCodeURL(`https://www.meshtastic.org/e/#${base64}`); setQRCodeURL(`https://meshtastic.org/e/#${base64}`);
}, [channels, selectedChannels, loraConfig]); }, [channels, selectedChannels, loraConfig]);
return ( return (
@ -85,10 +85,7 @@ export const QRDialog = ({
? "Primary" ? "Primary"
: `Channel: ${channel.index}` : `Channel: ${channel.index}`
} }
checked={ checked={selectedChannels.includes(channel.index)}
channel.index === 0 ||
selectedChannels.includes(channel.index)
}
onChange={() => { onChange={() => {
if (selectedChannels.includes(channel.index)) { if (selectedChannels.includes(channel.index)) {
setSelectedChannels( setSelectedChannels(

Loading…
Cancel
Save