chore: Add chatwoot:on-message event (#6425)

This commit is contained in:
Pranav Raj S
2023-02-09 12:48:22 -08:00
committed by GitHub
parent 53d5d2af3c
commit 8db40f2d82
4 changed files with 38 additions and 3 deletions

View File

@@ -23,7 +23,11 @@ import {
} from './bubbleHelpers';
import { isWidgetColorLighter } from 'shared/helpers/colorHelper';
import { dispatchWindowEvent } from 'shared/helpers/CustomEventHelper';
import { CHATWOOT_ERROR, CHATWOOT_READY } from '../widget/constants/sdkEvents';
import {
CHATWOOT_ERROR,
CHATWOOT_ON_MESSAGE,
CHATWOOT_READY,
} from '../widget/constants/sdkEvents';
import { SET_USER_ERROR } from '../widget/constants/errorTypes';
import { getUserCookieName } from './cookieHelpers';
import {
@@ -177,7 +181,9 @@ export const IFrameHelper = {
Cookies.remove(getUserCookieName());
}
},
onMessage({ data }) {
dispatchWindowEvent({ eventName: CHATWOOT_ON_MESSAGE, data });
},
setBubbleLabel(message) {
setBubbleText(window.$chatwoot.launcherTitle || message.label);
},