fix: Use exisiting bubble nodes if available (#2026)
This commit is contained in:
parent
bf8f19b334
commit
1b99ab3098
1 changed files with 10 additions and 1 deletions
|
@ -23,6 +23,11 @@ export const IFrameHelper = {
|
||||||
return `${baseUrl}/widget?website_token=${websiteToken}`;
|
return `${baseUrl}/widget?website_token=${websiteToken}`;
|
||||||
},
|
},
|
||||||
createFrame: ({ baseUrl, websiteToken }) => {
|
createFrame: ({ baseUrl, websiteToken }) => {
|
||||||
|
if (IFrameHelper.getAppFrame()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
loadCSS();
|
||||||
const iframe = document.createElement('iframe');
|
const iframe = document.createElement('iframe');
|
||||||
const cwCookie = Cookies.get('cw_conversation');
|
const cwCookie = Cookies.get('cw_conversation');
|
||||||
let widgetUrl = IFrameHelper.getUrl({ baseUrl, websiteToken });
|
let widgetUrl = IFrameHelper.getUrl({ baseUrl, websiteToken });
|
||||||
|
@ -47,6 +52,7 @@ export const IFrameHelper = {
|
||||||
IFrameHelper.preventDefaultScroll();
|
IFrameHelper.preventDefaultScroll();
|
||||||
},
|
},
|
||||||
getAppFrame: () => document.getElementById('chatwoot_live_chat_widget'),
|
getAppFrame: () => document.getElementById('chatwoot_live_chat_widget'),
|
||||||
|
getBubbleHolder: () => document.getElementsByClassName('woot--bubble-holder'),
|
||||||
sendMessage: (key, value) => {
|
sendMessage: (key, value) => {
|
||||||
const element = IFrameHelper.getAppFrame();
|
const element = IFrameHelper.getAppFrame();
|
||||||
element.contentWindow.postMessage(
|
element.contentWindow.postMessage(
|
||||||
|
@ -166,7 +172,10 @@ export const IFrameHelper = {
|
||||||
iframe.style.visibility = '';
|
iframe.style.visibility = '';
|
||||||
iframe.setAttribute('id', `chatwoot_live_chat_widget`);
|
iframe.setAttribute('id', `chatwoot_live_chat_widget`);
|
||||||
|
|
||||||
loadCSS();
|
if (IFrameHelper.getBubbleHolder().length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
createBubbleHolder();
|
createBubbleHolder();
|
||||||
|
|
||||||
if (!window.$chatwoot.hideMessageBubble) {
|
if (!window.$chatwoot.hideMessageBubble) {
|
||||||
|
|
Loading…
Reference in a new issue