mirror of https://github.com/vector-im/riot-web
don't pass back {} when we have no `org.matrix.room.color_scheme`
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>pull/21833/head
parent
952f2c6a21
commit
b90a98b5c1
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue