Send visibility only when changed, and messaging is available
This commit is contained in:
parent
a419056040
commit
9c5c5e282b
2 changed files with 14 additions and 14 deletions
|
@ -172,12 +172,7 @@ export default class AppTile extends React.Component {
|
||||||
componentDidUpdate() {
|
componentDidUpdate() {
|
||||||
// Allow parents to access widget messaging
|
// Allow parents to access widget messaging
|
||||||
if (this.props.collectWidgetMessaging) {
|
if (this.props.collectWidgetMessaging) {
|
||||||
this.props.collectWidgetMessaging(new Promise((resolve) => {
|
this.props.collectWidgetMessaging(this.widgetMessaging);
|
||||||
if (this.widgetMessaging) resolve(this.widgetMessaging);
|
|
||||||
|
|
||||||
// Expect this to be resolved later
|
|
||||||
this._exposeWidgetMessaging = resolve;
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -105,11 +105,7 @@ export default class Stickerpicker extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps, prevState) {
|
componentDidUpdate(prevProps, prevState) {
|
||||||
if (this._appWidgetMessaging &&
|
this._sendVisibilityToWidget(this.state.showStickers);
|
||||||
prevState.showStickers !== this.state.showStickers
|
|
||||||
) {
|
|
||||||
this._appWidgetMessaging.sendVisibility(this.state.showStickers);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_imError(errorMsg, e) {
|
_imError(errorMsg, e) {
|
||||||
|
@ -147,10 +143,19 @@ export default class Stickerpicker extends React.Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async _collectWidgetMessaging(prom) {
|
_collectWidgetMessaging(widgetMessaging) {
|
||||||
const widgetMessaging = await prom;
|
|
||||||
this._appWidgetMessaging = widgetMessaging;
|
this._appWidgetMessaging = widgetMessaging;
|
||||||
this._appWidgetMessaging.sendVisibility(true);
|
|
||||||
|
// Do this now instead of in componentDidMount because we might not have had the
|
||||||
|
// reference to widgetMessaging when mounting
|
||||||
|
this._sendVisibilityToWidget(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
_sendVisibilityToWidget(visible) {
|
||||||
|
if (this._appWidgetMessaging && visible !== this._prevSentVisibility) {
|
||||||
|
this._appWidgetMessaging.sendVisibility(visible);
|
||||||
|
this._prevSentVisibility = visible;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_getStickerpickerContent() {
|
_getStickerpickerContent() {
|
||||||
|
|
Loading…
Reference in a new issue