feat: Add the ability to close and reopen the chat window via SDK (#3080)

This commit is contained in:
Aswin Dev P.S 2021-09-28 19:25:44 +05:30 committed by GitHub
parent 1761bec615
commit edd0e2329f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View file

@ -40,8 +40,8 @@ const runSDK = ({ baseUrl, websiteToken }) => {
launcherTitle: chatwootSettings.launcherTitle || '',
showPopoutButton: chatwootSettings.showPopoutButton || false,
toggle() {
IFrameHelper.events.toggleBubble();
toggle(state) {
IFrameHelper.events.toggleBubble(state);
},
setUser(identifier, user) {

View file

@ -137,8 +137,15 @@ export const IFrameHelper = {
setBubbleText(window.$chatwoot.launcherTitle || message.label);
},
toggleBubble: () => {
onBubbleClick();
toggleBubble: state => {
let bubbleState = {};
if (state === 'open') {
bubbleState.toggleValue = true;
} else if (state === 'close') {
bubbleState.toggleValue = false;
}
onBubbleClick(bubbleState);
},
onBubbleToggle: isOpen => {