fix: Add resetTriggered flag to fix reset loop (#4079)

This commit is contained in:
Pranav Raj S 2022-02-28 14:53:11 +05:30 committed by GitHub
parent cebb1bf871
commit 87a6266ddc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -25,6 +25,7 @@ const runSDK = ({ baseUrl, websiteToken }) => {
launcherTitle: chatwootSettings.launcherTitle || '',
showPopoutButton: chatwootSettings.showPopoutButton || false,
widgetStyle: chatwootSettings.widgetStyle || 'standard',
resetTriggered: false,
toggle(state) {
IFrameHelper.events.toggleBubble(state);
@ -100,6 +101,8 @@ const runSDK = ({ baseUrl, websiteToken }) => {
baseUrl: window.$chatwoot.baseUrl,
websiteToken: window.$chatwoot.websiteToken,
});
window.$chatwoot.resetTriggered = true;
},
};

View file

@ -136,7 +136,9 @@ export const IFrameHelper = {
if (window.$chatwoot.user) {
IFrameHelper.sendMessage('set-user', window.$chatwoot.user);
}
dispatchWindowEvent({ eventName: CHATWOOT_READY });
if (!window.$chatwoot.resetTriggered) {
dispatchWindowEvent({ eventName: CHATWOOT_READY });
}
},
error: ({ errorType, data }) => {
dispatchWindowEvent({ eventName: CHATWOOT_ERROR, data: data });