From 1f2d279a0a8eee0beece47b5e154829de4088398 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 5 Jul 2018 19:38:42 +0100 Subject: [PATCH] Consistency, redundant check & doc --- src/stores/WidgetEchoStore.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/stores/WidgetEchoStore.js b/src/stores/WidgetEchoStore.js index f50d0fd962..3c2f79e951 100644 --- a/src/stores/WidgetEchoStore.js +++ b/src/stores/WidgetEchoStore.js @@ -25,6 +25,7 @@ class WidgetEchoStore extends EventEmitter { super(); this._roomWidgetEcho = { + // Map as below. For widgets that have been deleted locally, the object is empty. // roomId: { // widgetId: [object] // } @@ -49,7 +50,7 @@ class WidgetEchoStore extends EventEmitter { for (const w of currentRoomWidgets) { const widgetId = w.getStateKey(); - if (roomEchoState && roomEchoState[widgetId] && Object.keys(roomEchoState[widgetId]).length === 0) { + if (roomEchoState[widgetId] && Object.keys(roomEchoState[widgetId]).length === 0) { // delete locally so don't copy it // we don't include widgets that have changed for the same rason we don't include new ones, // so fall into the 'else' case and use the old one @@ -101,7 +102,7 @@ class WidgetEchoStore extends EventEmitter { removeRoomWidgetEcho(roomId, widgetId) { delete this._roomWidgetEcho[roomId][widgetId]; - if (this._roomWidgetEcho[roomId] === {}) delete this._roomWidgetEcho[roomId]; + if (Object.keys(this._roomWidgetEcho[roomId]).length === 0) delete this._roomWidgetEcho[roomId]; this.emit('updateRoomWidgetEcho'); } }