Don't set the transport until the user clicks suggestions or hits enter

This commit is contained in:
MotorTruck1221 2024-07-01 01:07:27 -06:00
parent a341b1dcbe
commit 9c01c9f65c
No known key found for this signature in database
GPG key ID: 08F417E2B8B61EA4
3 changed files with 5 additions and 4 deletions

View file

@ -8,6 +8,7 @@ import { enc } from "../aes";
import CloakedHead from "../util/CloakedHead"; import CloakedHead from "../util/CloakedHead";
import { useEffect } from "preact/hooks"; import { useEffect } from "preact/hooks";
import { updateServiceWorkers } from "../util/SWHelper.js"; import { updateServiceWorkers } from "../util/SWHelper.js";
import { setTransport } from "../util/transports";
export function Home() { export function Home() {
const [isFocused, setIsFocused] = useState(false); const [isFocused, setIsFocused] = useState(false);
@ -90,6 +91,7 @@ export function Home() {
const handleSubmit = (event) => { const handleSubmit = (event) => {
event.preventDefault(); event.preventDefault();
setTransport();
window.location.href = window.location.href =
"/go/" + "/go/" +
encodeURIComponent( encodeURIComponent(
@ -165,6 +167,7 @@ export function Home() {
{showSuggestions && {showSuggestions &&
suggestions.map((suggestion, index) => ( suggestions.map((suggestion, index) => (
<a <a
onClick={() => {setTransport()}}
href={ href={
"/go/" + "/go/" +
encodeURIComponent( encodeURIComponent(

View file

@ -8,7 +8,6 @@ import { Settings } from "./pages/Settings/";
import { AboutBlank } from "./AboutBlank"; import { AboutBlank } from "./AboutBlank";
import { Faq } from "./pages/Faq"; import { Faq } from "./pages/Faq";
// import { registerRemoteListener } from "@mercuryworkshop/bare-mux"; // import { registerRemoteListener } from "@mercuryworkshop/bare-mux";
import { setTransport } from "./util/transports";
import "./style.css"; import "./style.css";
import "./i18n"; import "./i18n";
@ -17,11 +16,10 @@ export default function Routes() {
(location.protocol === "https:" ? "wss://" : "ws://") + (location.protocol === "https:" ? "wss://" : "ws://") +
location.host + location.host +
"/wisp/"; // @TODO Japan - US ping "/wisp/"; // @TODO Japan - US ping
if ("serviceWorker" in navigator) { if ("serviceWorker" in navigator) {
navigator.serviceWorker.ready.then(async () => { navigator.serviceWorker.ready.then(async () => {
//await registerRemoteListener(sw.active!) //await registerRemoteListener(sw.active!)
setTransport(); console.log("SW ready")
}); });
navigator.serviceWorker.register("/sw.js", { navigator.serviceWorker.register("/sw.js", {
scope: "/" scope: "/"