Skip to content

Commit 7c55080

Browse files
author
Ritika Mishra
committed
improved logic of loading while connecting
1 parent 160a4fa commit 7c55080

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/components/Connection.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ const Connection: React.FC<ConnectionProps> = ({
432432
}
433433

434434
const connectToDevice = async () => {
435-
setIsLoading(true); // Set loading state to true
435+
436436
try {
437437
// Disconnect any previous connection if port is open
438438
if (portRef.current && portRef.current.readable) {
@@ -485,9 +485,12 @@ const Connection: React.FC<ConnectionProps> = ({
485485
});
486486
localStorage.setItem('savedDevices', JSON.stringify(savedPorts));
487487
setSelectedChannels([1]); // Set channel 1 as the default
488+
488489
// Open the port with the determined baud rate
489490
await port.open({ baudRate });
491+
setIsLoading(true); // Set loading state to true
490492
} else {
493+
setIsLoading(true); // Set loading state to true
491494
// If device is already found, retrieve its settings
492495
const info = port.getInfo();
493496
const savedDevice = savedPorts.find(

0 commit comments

Comments
 (0)