From db5d2d0329a48d25ab0a6d0c89846e30cd0928f2 Mon Sep 17 00:00:00 2001 From: Ronald Langeveld Date: Tue, 23 Jan 2024 10:05:12 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9BFixed=20primary=5Fname=20crashing?= =?UTF-8?q?=20Settings=20history=20(#19550)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes https://linear.app/tryghost/issue/PROD-329/history-modal-crashes-the-app - Added optional chaining operator to avoid null or undefined crashes when the condition doesn't meet and should rather just move on. - It now aligns with the other conditions where chaining is used. --- .../src/components/settings/advanced/HistoryModal.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/admin-x-settings/src/components/settings/advanced/HistoryModal.tsx b/apps/admin-x-settings/src/components/settings/advanced/HistoryModal.tsx index 6a55749ab8..d2423843a7 100644 --- a/apps/admin-x-settings/src/components/settings/advanced/HistoryModal.tsx +++ b/apps/admin-x-settings/src/components/settings/advanced/HistoryModal.tsx @@ -127,7 +127,7 @@ const HistoryActionDescription: React.FC<{action: Action}> = ({action}) => { {group.slice(0, 1).toUpperCase()}{group.slice(1)} {group !== key && ({key})} ; - } else if (action.resource?.title || action.resource?.name || action.context.primary_name) { + } else if (action.resource?.title || action.resource?.name || action.context?.primary_name) { const linkTarget = getLinkTarget(action); if (linkTarget) { @@ -136,7 +136,7 @@ const HistoryActionDescription: React.FC<{action: Action}> = ({action}) => { updateRoute(linkTarget); }}>{action.resource?.title || action.resource?.name}; } else { - return <>{action.resource?.title || action.resource?.name || action.context.primary_name}; + return <>{action.resource?.title || action.resource?.name || action.context?.primary_name}; } } else { return (unknown);