Oops, actually get account data event.

Also ignore any account data events that aren;t widgets.
This commit is contained in:
David Baker 2018-05-15 14:13:56 +01:00
parent f4d69e26e9
commit d0ec467c34

View file

@ -293,13 +293,20 @@ function inviteUser(event, roomId, userId) {
*/
function waitForUserWidget(widgetId) {
return new Promise((resolve, reject) => {
if (ev.getContent() && ev.getContent()[widgetId] !== undefined) {
const currentAccountDataEvent = MatrixClientPeg.get().getAccountData('m.widgets');
if (
currentAccountDataEvent &&
currentAccountDataEvent.getContent() &&
currentAccountDataEvent.getContent()[widgetId] !== undefined
) {
resolve();
return;
}
let timerId;
function onAccountData(ev) {
if (ev.getType() != 'm.widgets') return;
if (ev.getContent() && ev.getContent()[widgetId] !== undefined) {
MatrixClientPeg.get().removeListener('accountData', onAccountData);
clearTimeout(timerId);