be a bit more dilligent about including visitedBusses
This commit is contained in:
parent
8a4985e6a3
commit
f25749470b
@ -89,6 +89,7 @@ export default class EventBus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
send(command: string, commandData: any, context: EventBusContext = {}) {
|
send(command: string, commandData: any, context: EventBusContext = {}) {
|
||||||
|
context.visitedBusses = [...context.visitedBusses ?? [], this.uuid];
|
||||||
// execute commands we have subscriptions for
|
// execute commands we have subscriptions for
|
||||||
|
|
||||||
if (this.commands?.[command]) {
|
if (this.commands?.[command]) {
|
||||||
@ -111,30 +112,26 @@ export default class EventBus {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (command !== 'reload-required') {
|
if (command !== 'reload-required') {
|
||||||
// We shouldn't let reload-required command to trigger new reload-required commands.
|
// We shouldn't let reload-required command to trigger new reload-required commands.
|
||||||
this.send('reload-required', {});
|
this.send('reload-required', {}, {visitedBusses: [this.uuid]});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// call forwarding functions if they exist
|
// call forwarding functions if they exist
|
||||||
if (!context?.borderCrossings?.iframe) {
|
for (const forwarding of this.iframeForwardingList) {
|
||||||
for (const forwarding of this.iframeForwardingList) {
|
forwarding.fn(
|
||||||
forwarding.fn(
|
command,
|
||||||
command,
|
commandData,
|
||||||
commandData,
|
{
|
||||||
{
|
...context,
|
||||||
...context,
|
borderCrossings: {
|
||||||
borderCrossings: {
|
...context?.borderCrossings,
|
||||||
...context?.borderCrossings,
|
// iframe: true // we actually no longer check this prop, we should instead rely on visitedBusses
|
||||||
iframe: true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
}
|
||||||
}
|
);
|
||||||
this.sendToTunnel(command, commandData, context);
|
|
||||||
} else {
|
|
||||||
console.warn('message was already sent to iframe, doing nothing ...')
|
|
||||||
}
|
}
|
||||||
|
this.sendToTunnel(command, commandData, context);
|
||||||
|
|
||||||
if (context?.stopPropagation) {
|
if (context?.stopPropagation) {
|
||||||
return;
|
return;
|
||||||
@ -148,6 +145,10 @@ export default class EventBus {
|
|||||||
* @param config
|
* @param config
|
||||||
*/
|
*/
|
||||||
sendToTunnel(command: string, config: any, context: EventBusContext = {}) {
|
sendToTunnel(command: string, config: any, context: EventBusContext = {}) {
|
||||||
|
if (!context.visitedBusses) {
|
||||||
|
console.error('Visited busses is missing from contextn. This is illegal.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
context.visitedBusses = [...context.visitedBusses ?? [], this.uuid];
|
context.visitedBusses = [...context.visitedBusses ?? [], this.uuid];
|
||||||
|
|
||||||
if (!this.disableTunnel && typeof window !== 'undefined') {
|
if (!this.disableTunnel && typeof window !== 'undefined') {
|
||||||
@ -205,7 +206,7 @@ export default class EventBus {
|
|||||||
const payload = event.data.payload as EventBusMessage;
|
const payload = event.data.payload as EventBusMessage;
|
||||||
|
|
||||||
console.info(this.name, 'received message from iframe. command:', payload);
|
console.info(this.name, 'received message from iframe. command:', payload);
|
||||||
if (!payload.context) {
|
if (!payload.context?.visitedBusses) {
|
||||||
console.warn('Received iframe message without context. Doing nothing in order to avoid infinite loop. Event:', event);
|
console.warn('Received iframe message without context. Doing nothing in order to avoid infinite loop. Event:', event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user