From 7f6c531ca8ad5bee05f7340b700e3209667dfb2c Mon Sep 17 00:00:00 2001 From: Xendarboh <1435589+xendarboh@users.noreply.github.com> Date: Thu, 10 Apr 2025 16:54:28 -0700 Subject: [PATCH 1/4] fix: cross-platform handling of client stop vs fail --- src/pages/Networks.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/pages/Networks.tsx b/src/pages/Networks.tsx index 3d78365..90b5d0c 100644 --- a/src/pages/Networks.tsx +++ b/src/pages/Networks.tsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useRef, useState } from "react"; import * as log from "@tauri-apps/plugin-log"; import * as path from "@tauri-apps/api/path"; import { exists, mkdir } from "@tauri-apps/plugin-fs"; @@ -14,6 +14,7 @@ import { } from "../utils"; export function Networks() { + const isStoppingRef = useRef(false); const [dlProgress, setDlProgress] = useState(0); const [networkId, setNetworkId] = useState(""); @@ -52,9 +53,9 @@ export function Networks() { async function disconnect() { try { + isStoppingRef.current = true; await clientStop(); setMessage("info", "Disconnected from Network"); - consoleAddLine(`Disconnected from network: ${networkId}`); } catch (error: any) { log.error(`${error}`); setMessage("error", `${error}`); @@ -161,13 +162,13 @@ export function Networks() { log.debug(`spawning command: ${cmd} ${args.join(" ")}`); command.on("close", (data) => { - // normal: code=null signal=9 - // error: code=2 signal=null log.debug(`closed: ${cmd} code=${data.code} signal=${data.signal}`); - if (data.code !== null) { + if (!isStoppingRef.current) { setMessage("error", "Error: Network connection failed."); consoleAddLine(`Network connection failed: ${networkId}`); } + isStoppingRef.current = false; + consoleAddLine(`Disconnected from network: ${networkId}`); setClientPid(0); setIsConnected(false); setNetworkConnected(""); From a0ea210b8e9be4b3b2dac86c1bc2e873e69a2ed6 Mon Sep 17 00:00:00 2001 From: Xendarboh <1435589+xendarboh@users.noreply.github.com> Date: Thu, 10 Apr 2025 17:07:34 -0700 Subject: [PATCH 2/4] refactor: remove controlled input for console collapse --- src/components/Footer.tsx | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx index 04be039..9be11aa 100644 --- a/src/components/Footer.tsx +++ b/src/components/Footer.tsx @@ -1,10 +1,7 @@ -import { useState } from "react"; import { useStore } from "../store"; import { IconCommandLine } from "."; export function Footer() { - const [collapsed, setCollapsed] = useState(true as boolean); - const appVersion = useStore((s) => s.appVersion); const platformArch = useStore((s) => s.platformArch); const consoleLines = useStore((s) => s.consoleLines); @@ -12,13 +9,9 @@ export function Footer() { return (