From 6e0948c696cfbb45c31efb8828ccb50558d05c2c Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Fri, 31 Jan 2025 14:28:13 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9(frontend)=20prevent=20support=20to?= =?UTF-8?q?ggle=20when=20Crisp=20chat=20is=20blocked?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some users have ad-blockers or privacy extensions that prevent the Crisp chat widget script from loading properly. This was causing the support toggle to still display in rooms, but clicking it had no effect since Crisp was blocked. This ensures users don't see an inactive support button when their browser is blocking Crisp functionality. --- .../src/features/support/hooks/useSupport.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/frontend/src/features/support/hooks/useSupport.tsx b/src/frontend/src/features/support/hooks/useSupport.tsx index 9cbe94aa..4888fb90 100644 --- a/src/frontend/src/features/support/hooks/useSupport.tsx +++ b/src/frontend/src/features/support/hooks/useSupport.tsx @@ -31,7 +31,17 @@ export const useSupport = ({ id }: useSupportProps) => { return null } +// Some users may block Crisp chat widget with browser ad blockers or anti-tracking plugins +// So we need to safely check if Crisp is available and not blocked +const isCrispAvailable = () => { + try { + return !!window?.$crisp?.is + } catch { + return false + } +} + export const useIsSupportEnabled = () => { const { data } = useConfig() - return !!data?.support?.id + return !!data?.support?.id && isCrispAvailable() }