fix: read preferences value from state

This commit is contained in:
Johnny Almonte
2020-06-24 23:47:40 -04:00
parent 48261087c1
commit b944f3dec8

View File

@@ -951,7 +951,7 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
this.application.getPrefsService().syncUserPreferences(); this.application.getPrefsService().syncUserPreferences();
} }
reloadPreferences() { async reloadPreferences() {
const monospaceEnabled = this.application.getPrefsService().getValue( const monospaceEnabled = this.application.getPrefsService().getValue(
WebPrefKey.EditorMonospaceEnabled, WebPrefKey.EditorMonospaceEnabled,
true true
@@ -964,7 +964,7 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
WebPrefKey.EditorResizersEnabled, WebPrefKey.EditorResizersEnabled,
true true
); );
this.setEditorState({ await this.setEditorState({
monospaceEnabled, monospaceEnabled,
spellcheck, spellcheck,
marginResizersEnabled marginResizersEnabled
@@ -1020,12 +1020,15 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
} }
async toggleWebPrefKey(key: WebPrefKey) { async toggleWebPrefKey(key: WebPrefKey) {
(this as any)[key] = !(this as any)[key]; const currentValue = this.state[key];
this.application.getPrefsService().setUserPrefValue( await this.application.getPrefsService().setUserPrefValue(
key, key,
(this as any)[key], !currentValue,
true true
); );
await this.setEditorState({
[key]: !currentValue
})
this.reloadFont(); this.reloadFont();
if (key === WebPrefKey.EditorSpellcheck) { if (key === WebPrefKey.EditorSpellcheck) {
@@ -1033,7 +1036,7 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
await this.setEditorState({ textareaUnloading: false }); await this.setEditorState({ textareaUnloading: false });
this.setEditorState({ textareaUnloading: true }); this.setEditorState({ textareaUnloading: true });
this.reloadFont(); this.reloadFont();
} else if (key === WebPrefKey.EditorResizersEnabled && (this as any)[key] === true) { } else if (key === WebPrefKey.EditorResizersEnabled && this.state[key] === true) {
this.$timeout(() => { this.$timeout(() => {
this.leftPanelPuppet!.flash!(); this.leftPanelPuppet!.flash!();
this.rightPanelPuppet!.flash!(); this.rightPanelPuppet!.flash!();