fixed tls switch for http connections
This commit is contained in:
@@ -9,12 +9,12 @@ import { subscribeAll } from "@core/subscriptions.ts";
|
|||||||
import { randId } from "@core/utils/randId.ts";
|
import { randId } from "@core/utils/randId.ts";
|
||||||
import { HttpConnection } from "@meshtastic/js";
|
import { HttpConnection } from "@meshtastic/js";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { Controller, useForm, useWatch } from "react-hook-form";
|
import { Controller, useForm } from "react-hook-form";
|
||||||
|
|
||||||
export const HTTP = ({ closeDialog }: TabElementProps): JSX.Element => {
|
export const HTTP = ({ closeDialog }: TabElementProps): JSX.Element => {
|
||||||
const { addDevice } = useDeviceStore();
|
const { addDevice } = useDeviceStore();
|
||||||
const { setSelectedDevice } = useAppStore();
|
const { setSelectedDevice } = useAppStore();
|
||||||
const { register, handleSubmit, control } = useForm<{
|
const { register, handleSubmit, control, watch } = useForm<{
|
||||||
ip: string;
|
ip: string;
|
||||||
tls: boolean;
|
tls: boolean;
|
||||||
}>({
|
}>({
|
||||||
@@ -29,7 +29,7 @@ export const HTTP = ({ closeDialog }: TabElementProps): JSX.Element => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const [connectionInProgress, setConnectionInProgress] = useState(false);
|
const [connectionInProgress, setConnectionInProgress] = useState(false);
|
||||||
const [https, setHTTPS] = useState(false);
|
const https = watch("tls");
|
||||||
|
|
||||||
const onSubmit = handleSubmit(async (data) => {
|
const onSubmit = handleSubmit(async (data) => {
|
||||||
setConnectionInProgress(true);
|
setConnectionInProgress(true);
|
||||||
@@ -41,7 +41,7 @@ export const HTTP = ({ closeDialog }: TabElementProps): JSX.Element => {
|
|||||||
await connection.connect({
|
await connection.connect({
|
||||||
address: data.ip,
|
address: data.ip,
|
||||||
fetchInterval: 2000,
|
fetchInterval: 2000,
|
||||||
tls: https,
|
tls: data.tls,
|
||||||
});
|
});
|
||||||
|
|
||||||
setSelectedDevice(id);
|
setSelectedDevice(id);
|
||||||
@@ -64,13 +64,11 @@ export const HTTP = ({ closeDialog }: TabElementProps): JSX.Element => {
|
|||||||
<Controller
|
<Controller
|
||||||
name="tls"
|
name="tls"
|
||||||
control={control}
|
control={control}
|
||||||
render={({ field: { value, ...rest } }) => (
|
render={({ field: { value, onChange, ...rest } }) => (
|
||||||
<>
|
<>
|
||||||
<Label>Use HTTPS</Label>
|
<Label>Use HTTPS</Label>
|
||||||
<Switch
|
<Switch
|
||||||
onCheckedChange={(checked) => {
|
onCheckedChange={onChange}
|
||||||
checked ? setHTTPS(true) : setHTTPS(false);
|
|
||||||
}}
|
|
||||||
// label="Use TLS"
|
// label="Use TLS"
|
||||||
// description="Description"
|
// description="Description"
|
||||||
disabled={
|
disabled={
|
||||||
|
|||||||
Reference in New Issue
Block a user