From af88c5475bdd5b7f18ef641465816ded9aa6c170 Mon Sep 17 00:00:00 2001 From: MotorTruck1221 Date: Wed, 6 Mar 2024 01:02:13 -0700 Subject: [PATCH] Epoxy Transport setup and working (mostly0 --- index.html | 1 - src/pages/Settings/WispInput.tsx | 10 ++++++++-- src/util/transports.ts | 8 +++++--- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index e4b6ae1..d8ca197 100644 --- a/index.html +++ b/index.html @@ -16,7 +16,6 @@ scope: "/~/" }); }); - console.log("Service Worker Registered"); } diff --git a/src/pages/Settings/WispInput.tsx b/src/pages/Settings/WispInput.tsx index ed96529..dec8a8d 100644 --- a/src/pages/Settings/WispInput.tsx +++ b/src/pages/Settings/WispInput.tsx @@ -1,5 +1,6 @@ import { useState, useEffect } from "preact/hooks"; import { useTranslation } from "react-i18next"; +import { changeTransport } from "../../util/transports"; import { ToastContainer, toast } from "react-toastify"; interface WispInputProps { @@ -17,10 +18,15 @@ function WispInput(props: WispInputProps) { } else if (finalUrl.startsWith("https://")) { finalUrl = finalUrl.replace("https://", "wss://"); } + else if (finalUrl === "" || finalUrl === null || finalUrl === undefined) { + finalUrl = (location.protocol === "https:" ? "wss://" : "ws://") + location.host + "/wisp/"; + } + return finalUrl; } function handleChange() { - const url = validateUrl((document.getElementById("input") as HTMLInputElement).value); + const url = validateUrl((document.getElementById("wispinput") as HTMLInputElement).value); localStorage.setItem("wispUrl", url); + changeTransport(localStorage.getItem("transport") || "epoxy", url); } return (
@@ -35,7 +41,7 @@ function WispInput(props: WispInputProps) { handleChange(); } }} - id="input" + id="wispinput" className="font-roboto flex h-14 w-56 flex-row rounded-2xl border border-input-border-color bg-input p-4 text-center text-xl text-input-text" />