Skip to content
This repository has been archived by the owner on Aug 10, 2023. It is now read-only.

Commit

Permalink
Re-use existing sticker picker widgets
Browse files Browse the repository at this point in the history
There's a potential for a race condition by deleting then recreating the widget. Instead, we'll just re-use the widget and change the properties of it.

Fixes #200

Note that the actual change may not be reflected due to element-hq/element-web#7547
  • Loading branch information
turt2live committed Oct 24, 2018
1 parent 9ae83f3 commit a103f3c
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions web/app/configs/stickerpicker/stickerpicker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,11 @@ export class StickerpickerComponent implements OnInit {
try {
const widgets = await this.scalarClient.getWidgets();
const stickerPicker = widgets.response.find(w => w.content && w.content.type === "m.stickerpicker");
if (stickerPicker && !stickerPicker.content.data.dimension) {
console.log("Deleting non-Dimension sticker picker");
await this.scalarClient.deleteUserWidget(stickerPicker);
}
const widgetId = stickerPicker ? ((<any>stickerPicker).id || stickerPicker.state_key) : "dimension-stickerpicker-" + (new Date().getTime());

if (stickerPicker) return; // already have a widget

console.log("Adding Dimension sticker picker");
console.log("Force-setting new widget of ID " + widgetId);
await this.scalarClient.setUserWidget({
id: "dimension-stickerpicker-" + (new Date().getTime()),
id: widgetId,
type: WIDGET_STICKER_PICKER[0],
url: this.window.location.origin + "/widgets/stickerpicker",
data: {
Expand Down

0 comments on commit a103f3c

Please sign in to comment.