From 9a3f3562e12c05178048ce89feb91000a008dfee Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Thu, 29 Mar 2018 20:07:26 +0100 Subject: [PATCH] Wait for setAccountData to complete. --- src/ScalarMessaging.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ScalarMessaging.js b/src/ScalarMessaging.js index 351c178da4..dad1bdf6f6 100644 --- a/src/ScalarMessaging.js +++ b/src/ScalarMessaging.js @@ -355,12 +355,13 @@ function setWidget(event, roomId) { }; } - client.setAccountData('m.widgets', userWidgets); - sendResponse(event, { - success: true, - }); + client.setAccountData('m.widgets', userWidgets).then(() => { + sendResponse(event, { + success: true, + }); - dis.dispatch({ action: "user_widget_updated" }); + dis.dispatch({ action: "user_widget_updated" }); + }); } else { // Room widget if (!roomId) { sendError(event, _t('Missing roomId.'), null);