From 40289541ffff29955cde49a70aff23f2857d9f45 Mon Sep 17 00:00:00 2001 From: Nuzhy-Deriv Date: Thu, 21 Nov 2024 16:33:29 +0800 Subject: [PATCH] fix: condition to check fcWidget --- public/scripts/freshchat/freshchat-1.0.1.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/public/scripts/freshchat/freshchat-1.0.1.js b/public/scripts/freshchat/freshchat-1.0.1.js index 72975b67c6093..4204d00883eab 100644 --- a/public/scripts/freshchat/freshchat-1.0.1.js +++ b/public/scripts/freshchat/freshchat-1.0.1.js @@ -81,9 +81,14 @@ class FreshChat { script.onload = function () { if (jwt) { - window.fcWidget?.user?.setProperties({ - cf_user_jwt: jwt, - }); + const checkWidget = setInterval(() => { + if (window.fcWidget?.user) { + window.fcWidget.user?.setProperties({ + cf_user_jwt: jwt, + }); + clearInterval(checkWidget); + } + }, 500); } }; };