Fix URL preview options

Signed-off-by: Travis Ralston <travpc@gmail.com>
This commit is contained in:
Travis Ralston 2017-10-30 19:49:44 -06:00
parent 72517f95bb
commit 9c846e4dd9
4 changed files with 19 additions and 4 deletions

View file

@ -36,7 +36,7 @@ export default class RoomSettingsHandler extends SettingsHandler {
if (settingName === "urlPreviewsEnabled") {
const content = this._getSettings(roomId, "org.matrix.room.preview_urls");
content['disable'] = !newValue;
return MatrixClientPeg.get().setRoomAccountData(roomId, "org.matrix.room.preview_urls", content);
return MatrixClientPeg.get().sendStateEvent(roomId, "org.matrix.room.preview_urls", content);
}
const content = this._getSettings(roomId);

View file

@ -335,9 +335,11 @@ export default class SettingsStore {
* look at.
* @param {string} settingName The name of the setting to read.
* @param {String} roomId The room ID to read the setting value in, may be null.
* @param {boolean} explicit If true, this method will not consider other levels, just the one
* provided. Defaults to false.
* @return {*} The value, or null if not found.
*/
static getValueAt(level, settingName, roomId = null) {
static getValueAt(level, settingName, roomId = null, explicit = false) {
const minIndex = LEVEL_ORDER.indexOf(level);
if (minIndex === -1) throw new Error("Level " + level + " is not prioritized");
@ -350,6 +352,12 @@ export default class SettingsStore {
const handlers = SettingsStore._getHandlers(settingName);
if (explicit) {
let handler = handlers[level];
if (!handler) return null;
return handler.getValue(settingName, roomId);
}
for (let i = minIndex; i < LEVEL_ORDER.length; i++) {
let handler = handlers[LEVEL_ORDER[i]];
if (!handler) continue;
@ -379,6 +387,8 @@ export default class SettingsStore {
throw new Error("Setting " + settingName + " does not have a handler for " + level);
}
console.log("Setting " + settingName +" in " + roomId +" at " + level +" to " + value);
if (!handler.canSetValue(settingName, roomId)) {
throw new Error("User cannot set " + settingName + " at " + level + " in " + roomId);
}