Handle migration from useIRCLayout to layout

Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
pull/21833/head
Š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
1 changed files with 20 additions and 0 deletions

View File

@ -20,6 +20,7 @@ import SettingsHandler from "./SettingsHandler";
import {MatrixClientPeg} from "../../MatrixClientPeg"; import {MatrixClientPeg} from "../../MatrixClientPeg";
import {SettingLevel} from "../SettingLevel"; import {SettingLevel} from "../SettingLevel";
import { CallbackFn, WatchManager } from "../WatchManager"; import { CallbackFn, WatchManager } from "../WatchManager";
import { Layout } from "../Layout";
/** /**
* Gets and sets settings at the "device" level for the current device. * 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']; 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() || {}; const settings = this.getSettings() || {};
return settings[settingName]; return settings[settingName];
} }
@ -106,6 +114,18 @@ export default class DeviceSettingsHandler extends SettingsHandler {
return Promise.resolve(); 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() || {}; const settings = this.getSettings() || {};
settings[settingName] = newValue; settings[settingName] = newValue;
localStorage.setItem("mx_local_settings", JSON.stringify(settings)); localStorage.setItem("mx_local_settings", JSON.stringify(settings));