From 5a771b4ed0601aba6c7fc19982f8d3eb94eb1f50 Mon Sep 17 00:00:00 2001 From: Sylvia Crowe Date: Fri, 17 Jan 2025 18:28:17 -0800 Subject: [PATCH 1/2] fix: wsh error copy rewrite The previous version of this was giving undefined values for some users. This rewrites it and removes an unnecessary memo that may have been causing the issue. --- frontend/app/block/blockframe.tsx | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/frontend/app/block/blockframe.tsx b/frontend/app/block/blockframe.tsx index 2a14446b74..53c7ba72ab 100644 --- a/frontend/app/block/blockframe.tsx +++ b/frontend/app/block/blockframe.tsx @@ -422,21 +422,20 @@ const ConnStatusOverlay = React.memo( setShowWshError(showWshErrorTemp); }, [connStatus, wshConfigEnabled]); - const errorText = React.useMemo(() => { - const errTexts = []; - if (showError) { - errTexts.push(`error: ${connStatus.error}`); - } - if (showWshError) { - errTexts.push(`unable to use wsh: ${connStatus.error}`); - } - return errTexts.join("\n"); - }, [showError, connStatus.error, showWshError, connStatus.wsherror]); - - const handleCopy = async (e: React.MouseEvent) => { - let textToCopy = errorText; - await navigator.clipboard.writeText(textToCopy); - }; + const handleCopy = React.useCallback( + async (e: React.MouseEvent) => { + const errTexts = []; + if (showError) { + errTexts.push(`error: ${connStatus.error}`); + } + if (showWshError) { + errTexts.push(`unable to use wsh: ${connStatus.error}`); + } + const textToCopy = errTexts.join("\n"); + await navigator.clipboard.writeText(textToCopy); + }, + [showError, showWshError, connStatus.error, connStatus.wsherror] + ); if (!showWshError && (isLayoutMode || connStatus.status == "connected" || connModalOpen)) { return null; From 140a8df7b553c2e353522afbdacb59ca7071079b Mon Sep 17 00:00:00 2001 From: Sylvia Crowe Date: Fri, 17 Jan 2025 19:06:25 -0800 Subject: [PATCH 2/2] fix: use wsherror and error in conn err box --- frontend/app/block/blockframe.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/app/block/blockframe.tsx b/frontend/app/block/blockframe.tsx index 53c7ba72ab..bd8cbeeba6 100644 --- a/frontend/app/block/blockframe.tsx +++ b/frontend/app/block/blockframe.tsx @@ -429,7 +429,7 @@ const ConnStatusOverlay = React.memo( errTexts.push(`error: ${connStatus.error}`); } if (showWshError) { - errTexts.push(`unable to use wsh: ${connStatus.error}`); + errTexts.push(`unable to use wsh: ${connStatus.wsherror}`); } const textToCopy = errTexts.join("\n"); await navigator.clipboard.writeText(textToCopy);