From dc2c46e2a4b89f683153e72313aa7d9d97b35050 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Wed, 5 Jul 2023 14:02:39 -0700 Subject: [PATCH] fix(ui): fix for exception when chat is disabled. Closes #3138 --- web/components/ui/Content/Content.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/web/components/ui/Content/Content.tsx b/web/components/ui/Content/Content.tsx index 903e3d79d..3e2a1faad 100644 --- a/web/components/ui/Content/Content.tsx +++ b/web/components/ui/Content/Content.tsx @@ -132,12 +132,15 @@ export const Content: FC = () => { const externalActionSelected = (action: ExternalAction) => { const { openExternally, url } = action; - const { displayName } = currentUser; - const updatedUrl = new URL(url); - // Append url and username to params so the link knows where we came from and who we are. - updatedUrl.searchParams.append('username', displayName); updatedUrl.searchParams.append('instance', currentBrowserWindowUrl); + + if (currentUser) { + const { displayName } = currentUser; + + // Append url and username to params so the link knows where we came from and who we are. + updatedUrl.searchParams.append('username', displayName); + } const fullUrl = updatedUrl.toString(); // Overwrite URL with the updated one that includes the params. const updatedAction = { @@ -146,7 +149,7 @@ export const Content: FC = () => { }; // apply openExternally only if we don't have an HTML embed - if (openExternally && updatedAction) { + if (openExternally) { window.open(fullUrl, '_blank'); } else { setExternalActionToDisplay(updatedAction);