diff --git a/src/settings/Settings.js b/src/settings/Settings.js index 54446a467b..2220435cb9 100644 --- a/src/settings/Settings.js +++ b/src/settings/Settings.js @@ -283,6 +283,10 @@ export const SETTINGS = { supportedLevels: ['account'], default: true, }, + "allowedWidgets": { + supportedLevels: ['room-account'], + default: {}, // none allowed + }, "analyticsOptIn": { supportedLevels: LEVELS_DEVICE_ONLY_SETTINGS_WITH_CONFIG, displayName: _td('Send analytics data'), diff --git a/src/settings/handlers/RoomAccountSettingsHandler.js b/src/settings/handlers/RoomAccountSettingsHandler.js index 3c8a1f9941..f3a3cb643d 100644 --- a/src/settings/handlers/RoomAccountSettingsHandler.js +++ b/src/settings/handlers/RoomAccountSettingsHandler.js @@ -19,6 +19,8 @@ import MatrixClientPeg from '../../MatrixClientPeg'; import MatrixClientBackedSettingsHandler from "./MatrixClientBackedSettingsHandler"; import {SettingLevel} from "../SettingsStore"; +const ALLOWED_WIDGETS_EVENT_TYPE = "im.vector.setting.allowed_widgets"; + /** * Gets and sets settings at the "room-account" level for the current user. */ @@ -58,6 +60,8 @@ export default class RoomAccountSettingsHandler extends MatrixClientBackedSettin const val = event.getContent()[settingName]; this._watchers.notifyUpdate(settingName, roomId, SettingLevel.ROOM_ACCOUNT, val); } + } else if (event.getType() === ALLOWED_WIDGETS_EVENT_TYPE) { + this._watchers.notifyUpdate("allowedWidgets", roomId, SettingLevel.ROOM_ACCOUNT, event.getContent()); } } @@ -79,6 +83,11 @@ export default class RoomAccountSettingsHandler extends MatrixClientBackedSettin return this._getSettings(roomId, "org.matrix.room.color_scheme"); } + // Special case allowed widgets + if (settingName === "allowedWidgets") { + return this._getSettings(roomId, ALLOWED_WIDGETS_EVENT_TYPE); + } + const settings = this._getSettings(roomId) || {}; return settings[settingName]; } @@ -97,6 +106,11 @@ export default class RoomAccountSettingsHandler extends MatrixClientBackedSettin return MatrixClientPeg.get().setRoomAccountData(roomId, "org.matrix.room.color_scheme", newValue); } + // Special case allowed widgets + if (settingName === "allowedWidgets") { + return return MatrixClientPeg.get().setRoomAccountData(roomId, ALLOWED_WIDGETS_EVENT_TYPE, newValue); + } + const content = this._getSettings(roomId) || {}; content[settingName] = newValue; return MatrixClientPeg.get().setRoomAccountData(roomId, "im.vector.web.settings", content);