2019-10-29 07:20:54 +00:00
|
|
|
/* eslint-disable import/prefer-default-export */
|
|
|
|
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;
|
|
|
|
}, {});
|
2020-01-17 08:06:05 +00:00
|
|
|
|
|
|
|
export const IFrameHelper = {
|
|
|
|
isIFrame: () => window.self !== window.top,
|
|
|
|
sendMessage: msg => {
|
|
|
|
window.parent.postMessage(
|
|
|
|
`chatwoot-widget:${JSON.stringify({ ...msg })}`,
|
|
|
|
'*'
|
|
|
|
);
|
|
|
|
},
|
|
|
|
};
|