1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00

Electron: Save state of editor/viewer toggle

This commit is contained in:
Laurent Cozic
2017-11-12 17:02:20 +00:00
parent 2879e616c1
commit f9a06bb5b9
4 changed files with 52 additions and 13 deletions

View File

@ -142,12 +142,15 @@ class Setting extends BaseModel {
value = this.formatValue(key, value);
if (md.type == Setting.TYPE_INT) return value.toFixed(0);
if (md.type == Setting.TYPE_BOOL) return value ? '1' : '0';
if (md.type == Setting.TYPE_ARRAY) return value ? JSON.stringify(value) : '[]';
return value;
}
static formatValue(key, value) {
const md = this.settingMetadata(key);
if (md.type == Setting.TYPE_INT) return Math.floor(Number(value));
if (md.type == Setting.TYPE_BOOL) {
if (typeof value === 'string') {
value = value.toLowerCase();
@ -157,6 +160,13 @@ class Setting extends BaseModel {
}
return !!value;
}
if (md.type === Setting.TYPE_ARRAY) {
if (Array.isArray(value)) return value;
if (typeof value === 'string') return JSON.parse(value);
return [];
}
return value;
}
@ -297,6 +307,7 @@ class Setting extends BaseModel {
if (typeId === Setting.TYPE_INT) return 'int';
if (typeId === Setting.TYPE_STRING) return 'string';
if (typeId === Setting.TYPE_BOOL) return 'bool';
if (typeId === Setting.TYPE_ARRAY) return 'array';
}
}
@ -308,6 +319,7 @@ Setting.SYNC_TARGET_ONEDRIVE = 3;
Setting.TYPE_INT = 1;
Setting.TYPE_STRING = 2;
Setting.TYPE_BOOL = 3;
Setting.TYPE_ARRAY = 4;
Setting.THEME_LIGHT = 1;
Setting.THEME_DARK = 2;
@ -363,6 +375,7 @@ Setting.metadata_ = {
};
}},
'showAdvancedOptions': { value: false, type: Setting.TYPE_BOOL, public: true, appTypes: ['mobile', 'desktop'], label: () => _('Show advanced options') },
'noteVisiblePanes': { value: ['editor', 'viewer'], type: Setting.TYPE_ARRAY, public: false, appTypes: ['desktop'] },
};
// Contains constants that are set by the application and