Browse Source

fix qr dialog select

pull/101/head
Sacha Weatherstone 3 years ago
parent
commit
61db7580e0
No known key found for this signature in database GPG Key ID: 7AB2D7E206124B31
  1. 4
      src/components/Dialog/ImportDialog.tsx
  2. 15
      src/components/Dialog/QRDialog.tsx

4
src/components/Dialog/ImportDialog.tsx

@ -121,14 +121,14 @@ export const ImportDialog = ({
</span> </span>
<div className="flex w-40 flex-col gap-1"> <div className="flex w-40 flex-col gap-1">
{channelSet?.settings.map((channel, index) => ( {channelSet?.settings.map((channel, index) => (
<> <div className="flex justify-between" key={index}>
<Label> <Label>
{channel.name.length {channel.name.length
? channel.name ? channel.name
: `Channel: ${channel.id}`} : `Channel: ${channel.id}`}
</Label> </Label>
<Checkbox key={index} /> <Checkbox key={index} />
</> </div>
))} ))}
</div> </div>
</div> </div>

15
src/components/Dialog/QRDialog.tsx

@ -31,12 +31,11 @@ export const QRDialog = ({
const [selectedChannels, setSelectedChannels] = useState<number[]>([0]); const [selectedChannels, setSelectedChannels] = useState<number[]>([0]);
const [QRCodeURL, setQRCodeURL] = useState<string>(""); const [QRCodeURL, setQRCodeURL] = useState<string>("");
const filteredChannels = Array.from(channels.values()).filter((channel) => const allChannels = Array.from(channels.values());
selectedChannels.includes(channel.index)
);
useEffect(() => { useEffect(() => {
const channelsToEncode = filteredChannels const channelsToEncode = allChannels
.filter((ch) => selectedChannels.includes(ch.index))
.map((channel) => channel.settings) .map((channel) => channel.settings)
.filter((ch): ch is Protobuf.ChannelSettings => !!ch); .filter((ch): ch is Protobuf.ChannelSettings => !!ch);
const encoded = new Protobuf.ChannelSet( const encoded = new Protobuf.ChannelSet(
@ -64,9 +63,9 @@ export const QRDialog = ({
</DialogHeader> </DialogHeader>
<div className="grid gap-4 py-4"> <div className="grid gap-4 py-4">
<div className="flex gap-3 px-4 py-5 sm:p-6"> <div className="flex gap-3 px-4 py-5 sm:p-6">
<div className="flex w-40 flex-col gap-1"> <div className="flex w-40 flex-col gap-2">
{filteredChannels.map((channel) => ( {allChannels.map((channel) => (
<div key={channel.index}> <div className="flex justify-between" key={channel.index}>
<Label> <Label>
{channel.settings?.name.length {channel.settings?.name.length
? channel.settings.name ? channel.settings.name
@ -77,7 +76,7 @@ export const QRDialog = ({
<Checkbox <Checkbox
key={channel.index} key={channel.index}
checked={selectedChannels.includes(channel.index)} checked={selectedChannels.includes(channel.index)}
onChange={() => { onCheckedChange={() => {
if (selectedChannels.includes(channel.index)) { if (selectedChannels.includes(channel.index)) {
setSelectedChannels( setSelectedChannels(
selectedChannels.filter((c) => c !== channel.index) selectedChannels.filter((c) => c !== channel.index)

Loading…
Cancel
Save