Support a setting for allowed widgets
Hooking this setting up is left as a problem for a different issue.
This commit is contained in:
parent
28e0988325
commit
5af6d979c2
2 changed files with 18 additions and 0 deletions
|
@ -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'),
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue