Handle migration from useIRCLayout to layout

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
Šimon Brandner 2021-01-26 13:30:34 +01:00
parent 972c947049
commit 7efbd50e31
No known key found for this signature in database
GPG key ID: 9760693FDD98A790

View file

@ -20,6 +20,7 @@ import SettingsHandler from "./SettingsHandler";
import {MatrixClientPeg} from "../../MatrixClientPeg";
import {SettingLevel} from "../SettingLevel";
import { CallbackFn, WatchManager } from "../WatchManager";
import { Layout } from "../Layout";
/**
* Gets and sets settings at the "device" level for the current device.
@ -67,6 +68,13 @@ export default class DeviceSettingsHandler extends SettingsHandler {
return val['value'];
}
// Special case for old useIRCLayout setting
if (settingName === "layout") {
const settings = this.getSettings() || {};
if (settings["useIRCLayout"]) return Layout.IRC;
return settings[settingName];
}
const settings = this.getSettings() || {};
return settings[settingName];
}
@ -106,6 +114,18 @@ export default class DeviceSettingsHandler extends SettingsHandler {
return Promise.resolve();
}
// Special case for old useIRCLayout setting
if (settingName === "layout") {
const settings = this.getSettings() || {};
delete settings["useIRCLayout"];
settings["layout"] = newValue;
localStorage.setItem("mx_local_settings", JSON.stringify(settings));
this.watchers.notifyUpdate(settingName, null, SettingLevel.DEVICE, newValue);
return Promise.resolve();
}
const settings = this.getSettings() || {};
settings[settingName] = newValue;
localStorage.setItem("mx_local_settings", JSON.stringify(settings));