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

Commit 9c5c5e2

Browse files
committed
Send visibility only when changed, and messaging is available
1 parent a419056 commit 9c5c5e2

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/components/views/elements/AppTile.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,7 @@ export default class AppTile extends React.Component {
172172
componentDidUpdate() {
173173
// Allow parents to access widget messaging
174174
if (this.props.collectWidgetMessaging) {
175-
this.props.collectWidgetMessaging(new Promise((resolve) => {
176-
if (this.widgetMessaging) resolve(this.widgetMessaging);
177-
178-
// Expect this to be resolved later
179-
this._exposeWidgetMessaging = resolve;
180-
}));
175+
this.props.collectWidgetMessaging(this.widgetMessaging);
181176
}
182177
}
183178

src/components/views/rooms/Stickerpicker.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,7 @@ export default class Stickerpicker extends React.Component {
105105
}
106106

107107
componentDidUpdate(prevProps, prevState) {
108-
if (this._appWidgetMessaging &&
109-
prevState.showStickers !== this.state.showStickers
110-
) {
111-
this._appWidgetMessaging.sendVisibility(this.state.showStickers);
112-
}
108+
this._sendVisibilityToWidget(this.state.showStickers);
113109
}
114110

115111
_imError(errorMsg, e) {
@@ -147,10 +143,19 @@ export default class Stickerpicker extends React.Component {
147143
);
148144
}
149145

150-
async _collectWidgetMessaging(prom) {
151-
const widgetMessaging = await prom;
146+
_collectWidgetMessaging(widgetMessaging) {
152147
this._appWidgetMessaging = widgetMessaging;
153-
this._appWidgetMessaging.sendVisibility(true);
148+
149+
// Do this now instead of in componentDidMount because we might not have had the
150+
// reference to widgetMessaging when mounting
151+
this._sendVisibilityToWidget(true);
152+
}
153+
154+
_sendVisibilityToWidget(visible) {
155+
if (this._appWidgetMessaging && visible !== this._prevSentVisibility) {
156+
this._appWidgetMessaging.sendVisibility(visible);
157+
this._prevSentVisibility = visible;
158+
}
154159
}
155160

156161
_getStickerpickerContent() {

0 commit comments

Comments
 (0)