mirror of
https://github.com/turt2live/matrix-dimension.git
synced 2024-10-01 05:05:53 +00:00
Re-use existing sticker picker widgets
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 https://github.com/turt2live/matrix-dimension/issues/200 Note that the actual change may not be reflected due to https://github.com/vector-im/riot-web/issues/7547
This commit is contained in:
parent
9ae83f3dae
commit
a103f3ca6b
@ -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: {
|
||||
|
Loading…
Reference in New Issue
Block a user