Build out a store for the right panel state machine
This should make it easier to funnel the expected behaviour through a central block of code.
This commit is contained in:
parent
625e3ef93a
commit
5253f29928
4 changed files with 175 additions and 13 deletions
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
Copyright 2017 Travis Ralston
|
||||
Copyright 2019 New Vector Ltd.
|
||||
Copyright 2019 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
@ -56,6 +57,17 @@ export default class DeviceSettingsHandler extends SettingsHandler {
|
|||
return null; // wrong type or otherwise not set
|
||||
}
|
||||
|
||||
// Special case the right panel - see `setValue` for rationale.
|
||||
if ([
|
||||
"showRightPanelInRoom",
|
||||
"showRightPanelInGroup",
|
||||
"lastRightPanelPhaseForRoom",
|
||||
"lastRightPanelPhaseForGroup",
|
||||
].includes(settingName)) {
|
||||
const val = JSON.parse(localStorage.getItem(`mx_${settingName}`) || "{}");
|
||||
return val['value'];
|
||||
}
|
||||
|
||||
const settings = this._getSettings() || {};
|
||||
return settings[settingName];
|
||||
}
|
||||
|
@ -81,6 +93,20 @@ export default class DeviceSettingsHandler extends SettingsHandler {
|
|||
return Promise.resolve();
|
||||
}
|
||||
|
||||
// Special case the right panel because we want to be able to update these all
|
||||
// concurrently without stomping on one another. We could use async/await, though
|
||||
// that introduces just enough latency to be annoying.
|
||||
if ([
|
||||
"showRightPanelInRoom",
|
||||
"showRightPanelInGroup",
|
||||
"lastRightPanelPhaseForRoom",
|
||||
"lastRightPanelPhaseForGroup",
|
||||
].includes(settingName)) {
|
||||
localStorage.setItem(`mx_${settingName}`, JSON.stringify({value: newValue}));
|
||||
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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue