From 85d80be1cbc5bf991af3495b4001e3e86b5a07cc Mon Sep 17 00:00:00 2001 From: Nick Oliver Date: Thu, 16 May 2024 16:59:43 -0700 Subject: [PATCH 1/2] fix(Connect): disable connecting multiple times --- src/components/PageComponents/Connect/HTTP.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/PageComponents/Connect/HTTP.tsx b/src/components/PageComponents/Connect/HTTP.tsx index c780e415..046fea3b 100644 --- a/src/components/PageComponents/Connect/HTTP.tsx +++ b/src/components/PageComponents/Connect/HTTP.tsx @@ -1,3 +1,4 @@ +import React, { useState } from "react"; import { TabElementProps } from "@app/components/Dialog/NewDeviceDialog"; import { Button } from "@components/UI/Button.js"; import { Input } from "@components/UI/Input.js"; @@ -33,10 +34,13 @@ export const HTTP = ({ closeDialog }: TabElementProps): JSX.Element => { defaultValue: location.protocol === "https:", }); + const [connectionInProgress, setConnectionInProgress] = useState(false); + const onSubmit = handleSubmit(async (data) => { + setConnectionInProgress(true); + const id = randId(); const device = addDevice(id); - setSelectedDevice(id); const connection = new HttpConnection(id); // TODO: Promise never resolves await connection.connect({ @@ -44,9 +48,10 @@ export const HTTP = ({ closeDialog }: TabElementProps): JSX.Element => { fetchInterval: 2000, tls: data.tls, }); + + setSelectedDevice(id); device.addConnection(connection); subscribeAll(device, connection); - closeDialog(); }); @@ -77,8 +82,8 @@ export const HTTP = ({ closeDialog }: TabElementProps): JSX.Element => { )} /> - ); From 54d555941e1118813e2b5df334d760e388302644 Mon Sep 17 00:00:00 2001 From: Nick Oliver Date: Sat, 8 Jun 2024 22:54:47 -0700 Subject: [PATCH 2/2] fix(Connect): disable the address and TLS inputs when connecting --- src/components/PageComponents/Connect/HTTP.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/PageComponents/Connect/HTTP.tsx b/src/components/PageComponents/Connect/HTTP.tsx index 046fea3b..30e70169 100644 --- a/src/components/PageComponents/Connect/HTTP.tsx +++ b/src/components/PageComponents/Connect/HTTP.tsx @@ -63,6 +63,7 @@ export const HTTP = ({ closeDialog }: TabElementProps): JSX.Element => { // label="IP Address/Hostname" prefix={tlsEnabled ? "https://" : "http://"} placeholder="000.000.000.000 / meshtastic.local" + disabled={connectionInProgress} {...register("ip")} /> {