From ee4310cc41e26482fdf2e2444c4dee2023f583d7 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Sun, 25 Feb 2018 21:47:23 +0000 Subject: [PATCH] Avoid potential NPE. --- src/ScalarMessaging.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ScalarMessaging.js b/src/ScalarMessaging.js index abdea55506..7a9f85a9e0 100644 --- a/src/ScalarMessaging.js +++ b/src/ScalarMessaging.js @@ -335,7 +335,10 @@ function setWidget(event, roomId) { if (userWidget) { const client = MatrixClientPeg.get(); - const userWidgets = client.getAccountData('m.widgets').getContent() || {}; + let userWidgets = {}; + if (client.getAccountData('m.widgets')) { + userWidgets = client.getAccountData('m.widgets').getContent(); + } // Delete existing widget with ID try {