fix: wsh error copy rewrite (#1770)

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.
This commit is contained in:
Sylvie Crowe 2025-01-17 19:19:56 -08:00 committed by GitHub
parent ad3113e46e
commit 42766d096a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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.wsherror}`);
}
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;