From b90a98b5c1e46751dcd412ddd842d04c4d6d7171 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 17 Jan 2018 18:06:19 +0000 Subject: [PATCH] don't pass back {} when we have no `org.matrix.room.color_scheme` Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/settings/handlers/RoomAccountSettingsHandler.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/settings/handlers/RoomAccountSettingsHandler.js b/src/settings/handlers/RoomAccountSettingsHandler.js index e946581807..72355b43be 100644 --- a/src/settings/handlers/RoomAccountSettingsHandler.js +++ b/src/settings/handlers/RoomAccountSettingsHandler.js @@ -24,7 +24,7 @@ export default class RoomAccountSettingsHandler extends SettingsHandler { getValue(settingName, roomId) { // Special case URL previews if (settingName === "urlPreviewsEnabled") { - const content = this._getSettings(roomId, "org.matrix.room.preview_urls"); + const content = this._getSettings(roomId, "org.matrix.room.preview_urls") || {}; // Check to make sure that we actually got a boolean if (typeof(content['disable']) !== "boolean") return null; @@ -38,13 +38,14 @@ export default class RoomAccountSettingsHandler extends SettingsHandler { return this._getSettings(roomId, "org.matrix.room.color_scheme"); } - return this._getSettings(roomId)[settingName]; + const settings = this._getSettings(roomId) || {}; + return settings[settingName]; } setValue(settingName, roomId, newValue) { // Special case URL previews if (settingName === "urlPreviewsEnabled") { - const content = this._getSettings(roomId, "org.matrix.room.preview_urls"); + const content = this._getSettings(roomId, "org.matrix.room.preview_urls") || {}; content['disable'] = !newValue; return MatrixClientPeg.get().setRoomAccountData(roomId, "org.matrix.room.preview_urls", content); } @@ -55,7 +56,7 @@ export default class RoomAccountSettingsHandler extends SettingsHandler { return MatrixClientPeg.get().setRoomAccountData(roomId, "org.matrix.room.color_scheme", newValue); } - const content = this._getSettings(roomId); + const content = this._getSettings(roomId) || {}; content[settingName] = newValue; return MatrixClientPeg.get().setRoomAccountData(roomId, "im.vector.web.settings", content); } @@ -74,10 +75,10 @@ export default class RoomAccountSettingsHandler extends SettingsHandler { _getSettings(roomId, eventType = "im.vector.settings") { const room = MatrixClientPeg.get().getRoom(roomId); - if (!room) return {}; + if (!room) return null; const event = room.getAccountData(eventType); - if (!event || !event.getContent()) return {}; + if (!event || !event.getContent()) return null; return event.getContent(); } }