The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/client/lib/utils/fireGlobalEvent.ts

26 lines
582 B

import { Tracker } from 'meteor/tracker';
import { settings } from '../../../app/settings/client';
export const fireGlobalEvent = (eventName: string, detail?: unknown): void => {
window.dispatchEvent(new CustomEvent(eventName, { detail }));
Tracker.autorun((computation) => {
const enabled = settings.get('Iframe_Integration_send_enable');
if (enabled === undefined) {
return;
}
computation.stop();
if (enabled) {
parent.postMessage(
{
eventName,
data: detail,
},
settings.get('Iframe_Integration_send_target_origin'),
);
}
});
};