Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit bd0301c

Browse files
committed
Add API to send visibiliy actions to widgets
1 parent 42c59b5 commit bd0301c

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/WidgetMessaging.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ export default class WidgetMessaging {
9494
});
9595
}
9696

97+
sendVisibility(visible) {
98+
return this.messageToWidget({
99+
api: OUTBOUND_API_NAME,
100+
action: "visibility",
101+
visible,
102+
})
103+
.catch((error) => {
104+
console.error("Failed to send visibility: ", error);
105+
});
106+
}
97107

98108
start() {
99109
this.fromWidget.addEndpoint(this.widgetId, this.widgetUrl);

src/components/views/elements/AppTile.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,10 @@ export default class AppTile extends React.Component {
389389
}).catch((err) => {
390390
console.log(`Failed to get capabilities for widget type ${this.props.type}`, this.props.id, err);
391391
});
392+
393+
// Allow parents to access widget messaging
394+
if (this.props.collectWidgetMessaging) this.props.collectWidgetMessaging(this.widgetMessaging);
395+
392396
this.setState({loading: false});
393397
}
394398

0 commit comments

Comments
 (0)