Add error handling for failure to connect to integration manager.

This commit is contained in:
Richard Lewis 2018-02-23 10:20:16 +00:00
parent 9a5c916570
commit 88288ff3f5

View file

@ -49,6 +49,7 @@ export default class Stickerpack extends React.Component {
this.state = { this.state = {
stickersContent: this.defaultStickersContent, stickersContent: this.defaultStickersContent,
showStickers: false, showStickers: false,
imError: null,
}; };
} }
@ -56,7 +57,7 @@ export default class Stickerpack extends React.Component {
console.warn('Removing stickerpack widgets'); console.warn('Removing stickerpack widgets');
Widgets.removeStickerpackWidgets(); Widgets.removeStickerpackWidgets();
this._getStickerPickerWidget(); this._getStickerPickerWidget();
this.onFinished(); this.stickersMenu.close();
} }
componentDidMount() { componentDidMount() {
@ -66,21 +67,30 @@ export default class Stickerpack extends React.Component {
this.scalarClient.connect().then(() => { this.scalarClient.connect().then(() => {
this.forceUpdate(); this.forceUpdate();
}).catch((e) => { }).catch((e) => {
console.log("Failed to connect to integrations server"); this._imError("Failed to connect to integrations server", e);
// TODO -- Handle Scalar errors
// this.setState({
// scalar_error: err,
// });
}); });
} }
if (!this.state.imError) {
this._getStickerPickerWidget(); this._getStickerPickerWidget();
this.dispatcherRef = dis.register(this._onWidgetAction); this.dispatcherRef = dis.register(this._onWidgetAction);
} }
}
componentWillUnmount() { componentWillUnmount() {
dis.unregister(this.dispatcherRef); dis.unregister(this.dispatcherRef);
} }
_imError(errorMsg, e) {
console.error(errorMsg, e);
const imErrorContent = <div style={{"text-align": "center"}} className="error"><p> { errorMsg } </p></div>;
this.setState({
showStickers: false,
imError: errorMsg,
stickersContent: imErrorContent,
});
}
_onWidgetAction(payload) { _onWidgetAction(payload) {
if (payload.action === "user_widget_updated") { if (payload.action === "user_widget_updated") {
console.warn("user widget updated"); console.warn("user widget updated");