Skip to content

Commit

Permalink
Wait for iframe setting to start sending postMessages
Browse files Browse the repository at this point in the history
  • Loading branch information
sampaiodiego committed Apr 25, 2017
1 parent 7b636a7 commit e600442
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions packages/rocketchat-ui/client/lib/fireEvent.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
window.fireGlobalEvent = (eventName, params) => {
window.dispatchEvent(new CustomEvent(eventName, {detail: params}));

if (RocketChat.settings.get('Iframe_Integration_send_enable') === true) {
parent.postMessage({
eventName,
data: params
}, RocketChat.settings.get('Iframe_Integration_send_target_origin'));
}
window.fireGlobalEvent = function _fireGlobalEvent(eventName, params) {
Tracker.autorun((computation) => {
const enabled = RocketChat.settings.get('Iframe_Integration_send_enable');
if (enabled === undefined) {
return;
}
computation.stop();
if (enabled) {
window.dispatchEvent(new CustomEvent(eventName, {detail: params}));
parent.postMessage({
eventName,
data: params
}, RocketChat.settings.get('Iframe_Integration_send_target_origin'));
}
});
};

0 comments on commit e600442

Please sign in to comment.