Save peopleDrawer visibility in localStorage

Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
Ajay Bura
2021-11-15 09:23:59 +05:30
parent 1487dcbadc
commit cb6e71e544
7 changed files with 30 additions and 16 deletions

View File

@@ -24,6 +24,7 @@ class Settings extends EventEmitter {
this.themeIndex = this.getThemeIndex();
this.isMarkdown = this.getIsMarkdown();
this.isPeopleDrawer = this.getIsPeopleDrawer();
this.isTouchScreenDevice = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0);
}
@@ -62,6 +63,15 @@ class Settings extends EventEmitter {
return settings.isMarkdown;
}
getIsPeopleDrawer() {
if (typeof this.isPeopleDrawer === 'boolean') return this.isPeopleDrawer;
const settings = getSettings();
if (settings === null) return true;
if (typeof settings.isPeopleDrawer === 'undefined') return true;
return settings.isPeopleDrawer;
}
setter(action) {
const actions = {
[cons.actions.settings.TOGGLE_MARKDOWN]: () => {
@@ -69,6 +79,11 @@ class Settings extends EventEmitter {
setSettings('isMarkdown', this.isMarkdown);
this.emit(cons.events.settings.MARKDOWN_TOGGLED, this.isMarkdown);
},
[cons.actions.settings.TOGGLE_PEOPLE_DRAWER]: () => {
this.isPeopleDrawer = !this.isPeopleDrawer;
setSettings('isPeopleDrawer', this.isPeopleDrawer);
this.emit(cons.events.settings.PEOPLE_DRAWER_TOGGLED, this.isPeopleDrawer);
},
};
actions[action.type]?.();