From d82a05fbae4603d70b36daa6e2e24eb511ffbfb8 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 2 Oct 2019 15:26:54 +0100 Subject: [PATCH] Fix integration manager not updating when set setUserWidget was modifying the content of the old event itself, so when `waitForUserWidget()` checked the content to see if it was there yet, it was, but because the echo hadn't come back, the IntegrationManager hadn't rebuilt its list. In other news, its terrifying that we can just accidentally modify the content of an event in the store. I'm going to make a js-sdk PR that freezes the content and see what breaks... Fixes https://github.com/vector-im/riot-web/issues/10977 --- src/utils/WidgetUtils.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils/WidgetUtils.js b/src/utils/WidgetUtils.js index 237db82365..36907da5ab 100644 --- a/src/utils/WidgetUtils.js +++ b/src/utils/WidgetUtils.js @@ -233,7 +233,9 @@ export default class WidgetUtils { }; const client = MatrixClientPeg.get(); - const userWidgets = WidgetUtils.getUserWidgets(); + // Get the current widgets and clone them before we modify them, otherwise + // we'll modify the content of the old event. + const userWidgets = JSON.parse(JSON.stringify(WidgetUtils.getUserWidgets())); // Delete existing widget with ID try {