Migrate blacklistUnverifiedDevicesPerRoom
This currently causes a split-brain scenario for the application due to the priority of each level. Granular settings assumes a simple override, however the crypto setting wants per room to be overriden with the global setting, regardless of the room setting. Some additional comments are needed on the intended behaviour. Signed-off-by: Travis Ralston <travpc@gmail.com>
This commit is contained in:
parent
c7eee36990
commit
cb17c0a379
5 changed files with 52 additions and 45 deletions
|
@ -23,12 +23,30 @@ import SettingsHandler from "./SettingsHandler";
|
|||
*/
|
||||
export default class RoomDeviceSettingsHandler extends SettingsHandler {
|
||||
getValue(settingName, roomId) {
|
||||
const value = localStorage.getItem(this._getKey(settingName, roomId));
|
||||
if (!value) return null;
|
||||
return JSON.parse(value).value;
|
||||
// Special case blacklist setting to use legacy values
|
||||
if (settingName === "blacklistUnverifiedDevices") {
|
||||
const value = this._read("mx_local_settings");
|
||||
if (value && value['blacklistUnverifiedDevicesPerRoom']) {
|
||||
return value['blacklistUnverifiedDevicesPerRoom'][roomId];
|
||||
}
|
||||
}
|
||||
|
||||
const value = this._read(this._getKey(settingName, roomId));
|
||||
if (value) return value.value;
|
||||
return null;
|
||||
}
|
||||
|
||||
setValue(settingName, roomId, newValue) {
|
||||
// Special case blacklist setting for legacy structure
|
||||
if (settingName === "blacklistUnverifiedDevices") {
|
||||
let value = this._read("mx_local_settings");
|
||||
if (!value) value = {};
|
||||
if (!value["blacklistUnverifiedDevicesPerRoom"]) value["blacklistUnverifiedDevicesPerRoom"] = {};
|
||||
value["blacklistUnverifiedDevicesPerRoom"][roomId] = newValue;
|
||||
localStorage.setItem("mx_local_settings", JSON.stringify(value));
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
if (newValue === null) {
|
||||
localStorage.removeItem(this._getKey(settingName, roomId));
|
||||
} else {
|
||||
|
@ -47,6 +65,12 @@ export default class RoomDeviceSettingsHandler extends SettingsHandler {
|
|||
return localStorage !== undefined && localStorage !== null;
|
||||
}
|
||||
|
||||
_read(key) {
|
||||
const rawValue = localStorage.getItem(key);
|
||||
if (!rawValue) return null;
|
||||
return JSON.parse(rawValue);
|
||||
}
|
||||
|
||||
_getKey(settingName, roomId) {
|
||||
return "mx_setting_" + settingName + "_" + roomId;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue