mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-03 04:27:53 +00:00
chore: Refactor widget (#5621)
This commit is contained in:
@@ -10,7 +10,7 @@ export const loadedEventConfig = () => {
|
||||
|
||||
export const getExtraSpaceToScroll = () => {
|
||||
// This function calculates the extra space needed for the view to
|
||||
// accomodate the height of close button + height of
|
||||
// accommodate the height of close button + height of
|
||||
// read messages button. So that scrollbar won't appear
|
||||
const unreadMessageWrap = document.querySelector('.unread-messages');
|
||||
const unreadCloseWrap = document.querySelector('.close-unread-wrap');
|
||||
|
||||
@@ -3,13 +3,6 @@ import { WOOT_PREFIX } from './constants';
|
||||
export const isEmptyObject = obj =>
|
||||
Object.keys(obj).length === 0 && obj.constructor === Object;
|
||||
|
||||
export const arrayToHashById = array =>
|
||||
array.reduce((map, obj) => {
|
||||
const newMap = map;
|
||||
newMap[obj.id] = obj;
|
||||
return newMap;
|
||||
}, {});
|
||||
|
||||
export const sendMessage = msg => {
|
||||
window.parent.postMessage(
|
||||
`chatwoot-widget:${JSON.stringify({ ...msg })}`,
|
||||
@@ -22,9 +15,7 @@ export const IFrameHelper = {
|
||||
sendMessage,
|
||||
isAValidEvent: e => {
|
||||
const isDataAString = typeof e.data === 'string';
|
||||
const isAValidWootEvent =
|
||||
isDataAString && e.data.indexOf(WOOT_PREFIX) === 0;
|
||||
return isAValidWootEvent;
|
||||
return isDataAString && e.data.indexOf(WOOT_PREFIX) === 0;
|
||||
},
|
||||
getMessage: e => JSON.parse(e.data.replace(WOOT_PREFIX, '')),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user