feat: Add the SDK method to programatically toggle live chat bubble (#4223)
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
parent
80b8f5f915
commit
ef850eda0f
10 changed files with 79 additions and 28 deletions
|
@ -10,7 +10,8 @@ import {
|
|||
getUserCookieName,
|
||||
hasUserKeys,
|
||||
} from '../sdk/cookieHelpers';
|
||||
|
||||
import { addClass, removeClass } from '../sdk/DOMHelpers';
|
||||
import { SDK_SET_BUBBLE_VISIBILITY } from 'shared/constants/sharedFrameEvents';
|
||||
const runSDK = ({ baseUrl, websiteToken }) => {
|
||||
if (window.$chatwoot) {
|
||||
return;
|
||||
|
@ -36,6 +37,23 @@ const runSDK = ({ baseUrl, websiteToken }) => {
|
|||
IFrameHelper.events.toggleBubble(state);
|
||||
},
|
||||
|
||||
toggleBubbleVisibility(visibility) {
|
||||
let widgetElm = document.querySelector('.woot--bubble-holder');
|
||||
let widgetHolder = document.querySelector('.woot-widget-holder');
|
||||
if (visibility === 'hide') {
|
||||
addClass(widgetHolder, 'woot-widget--without-bubble');
|
||||
addClass(widgetElm, 'woot-hidden');
|
||||
window.$chatwoot.hideMessageBubble = true;
|
||||
} else if (visibility === 'show') {
|
||||
removeClass(widgetElm, 'woot-hidden');
|
||||
removeClass(widgetHolder, 'woot-widget--without-bubble');
|
||||
window.$chatwoot.hideMessageBubble = false;
|
||||
}
|
||||
IFrameHelper.sendMessage(SDK_SET_BUBBLE_VISIBILITY, {
|
||||
hideMessageBubble: window.$chatwoot.hideMessageBubble,
|
||||
});
|
||||
},
|
||||
|
||||
popoutChatWindow() {
|
||||
IFrameHelper.events.popoutChatWindow({
|
||||
baseUrl: window.$chatwoot.baseUrl,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue