Disable all widget assets on widget removal.
This commit is contained in:
parent
332892fee6
commit
86461bc88f
2 changed files with 37 additions and 0 deletions
|
@ -148,6 +148,33 @@ class ScalarAuthClient {
|
||||||
return defer.promise;
|
return defer.promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disableWidgetAssets(widgetType, widgetId) {
|
||||||
|
let url = SdkConfig.get().integrations_rest_url + '/widgets/set_assets_state';
|
||||||
|
url = this.getStarterLink(url);
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
request({
|
||||||
|
method: 'GET',
|
||||||
|
uri: url,
|
||||||
|
json: true,
|
||||||
|
qs: {
|
||||||
|
'widget_type': widgetType,
|
||||||
|
'widget_id': widgetId,
|
||||||
|
'state': 'disable',
|
||||||
|
},
|
||||||
|
}, (err, response, body) => {
|
||||||
|
if (err) {
|
||||||
|
reject(err);
|
||||||
|
} else if (response.statusCode / 100 !== 2) {
|
||||||
|
reject({statusCode: response.statusCode});
|
||||||
|
} else if (!body) {
|
||||||
|
reject(new Error("Failed to set widget assets state"));
|
||||||
|
} else {
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
getScalarInterfaceUrlForRoom(room, screen, id) {
|
getScalarInterfaceUrlForRoom(room, screen, id) {
|
||||||
const roomId = room.roomId;
|
const roomId = room.roomId;
|
||||||
const roomName = room.name;
|
const roomName = room.name;
|
||||||
|
|
|
@ -55,6 +55,15 @@ export default class Stickerpack extends React.Component {
|
||||||
|
|
||||||
_removeStickerpackWidgets() {
|
_removeStickerpackWidgets() {
|
||||||
console.warn('Removing stickerpack widgets');
|
console.warn('Removing stickerpack widgets');
|
||||||
|
if (this.widgetId) {
|
||||||
|
this.scalarClient.disableWidgetAssets('stickerpack', this.widgetId).then(() => {
|
||||||
|
console.warn('Assets disabled');
|
||||||
|
}).catch((err) => {
|
||||||
|
console.error('Failed to disable assets');
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.warn('No widget ID specified, not disabling assets');
|
||||||
|
}
|
||||||
Widgets.removeStickerpackWidgets();
|
Widgets.removeStickerpackWidgets();
|
||||||
this._getStickerPickerWidget();
|
this._getStickerPickerWidget();
|
||||||
this.stickersMenu.close();
|
this.stickersMenu.close();
|
||||||
|
@ -151,6 +160,7 @@ export default class Stickerpack extends React.Component {
|
||||||
// Default content to show if stickerpack widget not added
|
// Default content to show if stickerpack widget not added
|
||||||
console.warn("No available sticker picker widgets");
|
console.warn("No available sticker picker widgets");
|
||||||
stickersContent = this.defaultStickersContent;
|
stickersContent = this.defaultStickersContent;
|
||||||
|
this.widgetId = null;
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
}
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
|
|
Loading…
Reference in a new issue