Fixes user prefs sync race condition
This commit is contained in:
@@ -60,8 +60,8 @@ export class PreferencesManager extends ApplicationService {
|
|||||||
return (value !== undefined && value !== null) ? value : defaultValue;
|
return (value !== undefined && value !== null) ? value : defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
setUserPrefValue(key: WebPrefKey, value: any, sync = false) {
|
async setUserPrefValue(key: WebPrefKey, value: any, sync = false) {
|
||||||
this.application!.changeItem(
|
await this.application!.changeItem(
|
||||||
this.userPreferences.uuid,
|
this.userPreferences.uuid,
|
||||||
(m) => {
|
(m) => {
|
||||||
const mutator = m as UserPrefsMutator;
|
const mutator = m as UserPrefsMutator;
|
||||||
|
|||||||
@@ -477,7 +477,7 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
|
|||||||
}
|
}
|
||||||
if (this.editor.isTemplateNote) {
|
if (this.editor.isTemplateNote) {
|
||||||
await this.editor.insertTemplatedNote();
|
await this.editor.insertTemplatedNote();
|
||||||
if (this.appState.selectedTag) {
|
if (this.appState.selectedTag?.isSmartTag() === false) {
|
||||||
await this.application.changeItem(
|
await this.application.changeItem(
|
||||||
this.appState.selectedTag!.uuid,
|
this.appState.selectedTag!.uuid,
|
||||||
(mutator) => {
|
(mutator) => {
|
||||||
@@ -879,15 +879,15 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
|
|||||||
this.reloadTagsString();
|
this.reloadTagsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
onPanelResizeFinish(width: number, left: number, isMaxWidth: boolean) {
|
async onPanelResizeFinish(width: number, left: number, isMaxWidth: boolean) {
|
||||||
if (isMaxWidth) {
|
if (isMaxWidth) {
|
||||||
this.application.getPrefsService().setUserPrefValue(
|
await this.application.getPrefsService().setUserPrefValue(
|
||||||
WebPrefKey.EditorWidth,
|
WebPrefKey.EditorWidth,
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if (width !== undefined && width !== null) {
|
if (width !== undefined && width !== null) {
|
||||||
this.application.getPrefsService().setUserPrefValue(
|
await this.application.getPrefsService().setUserPrefValue(
|
||||||
WebPrefKey.EditorWidth,
|
WebPrefKey.EditorWidth,
|
||||||
width
|
width
|
||||||
);
|
);
|
||||||
@@ -895,7 +895,7 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (left !== undefined && left !== null) {
|
if (left !== undefined && left !== null) {
|
||||||
this.application.getPrefsService().setUserPrefValue(
|
await this.application.getPrefsService().setUserPrefValue(
|
||||||
WebPrefKey.EditorLeft,
|
WebPrefKey.EditorLeft,
|
||||||
left
|
left
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -400,9 +400,9 @@ class NotesViewCtrl extends PureViewCtrl {
|
|||||||
) {
|
) {
|
||||||
this.application!.getPrefsService().setUserPrefValue(
|
this.application!.getPrefsService().setUserPrefValue(
|
||||||
WebPrefKey.NotesPanelWidth,
|
WebPrefKey.NotesPanelWidth,
|
||||||
newWidth
|
newWidth,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
this.application!.getPrefsService().syncUserPreferences();
|
|
||||||
this.application!.getAppState().panelDidResize(
|
this.application!.getAppState().panelDidResize(
|
||||||
PANEL_NAME_NOTES,
|
PANEL_NAME_NOTES,
|
||||||
isCollapsed
|
isCollapsed
|
||||||
@@ -563,7 +563,7 @@ class NotesViewCtrl extends PureViewCtrl {
|
|||||||
const note = this.getFirstNonProtectedNote();
|
const note = this.getFirstNonProtectedNote();
|
||||||
if (note) {
|
if (note) {
|
||||||
this.selectNote(note);
|
this.selectNote(note);
|
||||||
} else if (!this.appState.selectedTag|| !this.appState.selectedTag.isSmartTag()) {
|
} else if (!this.appState.selectedTag || !this.appState.selectedTag.isSmartTag()) {
|
||||||
this.createPlaceholderNote();
|
this.createPlaceholderNote();
|
||||||
} else {
|
} else {
|
||||||
this.appState.closeActiveEditor();
|
this.appState.closeActiveEditor();
|
||||||
@@ -624,8 +624,11 @@ class NotesViewCtrl extends PureViewCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toggleWebPrefKey(key: WebPrefKey) {
|
toggleWebPrefKey(key: WebPrefKey) {
|
||||||
this.application!.getPrefsService().setUserPrefValue(key, !this.state[key]);
|
this.application!.getPrefsService().setUserPrefValue(
|
||||||
this.application!.getPrefsService().syncUserPreferences();
|
key,
|
||||||
|
!this.state[key],
|
||||||
|
true
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedSortByCreated() {
|
selectedSortByCreated() {
|
||||||
@@ -644,17 +647,17 @@ class NotesViewCtrl extends PureViewCtrl {
|
|||||||
this.selectedMenuItem();
|
this.selectedMenuItem();
|
||||||
this.application!.getPrefsService().setUserPrefValue(
|
this.application!.getPrefsService().setUserPrefValue(
|
||||||
WebPrefKey.SortNotesReverse,
|
WebPrefKey.SortNotesReverse,
|
||||||
!this.getState().sortReverse
|
!this.getState().sortReverse,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
this.application!.getPrefsService().syncUserPreferences();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setSortBy(type: NoteSortKey) {
|
setSortBy(type: NoteSortKey) {
|
||||||
this.application!.getPrefsService().setUserPrefValue(
|
this.application!.getPrefsService().setUserPrefValue(
|
||||||
WebPrefKey.SortNotesBy,
|
WebPrefKey.SortNotesBy,
|
||||||
type
|
type,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
this.application!.getPrefsService().syncUserPreferences();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getSearchBar() {
|
getSearchBar() {
|
||||||
|
|||||||
319
dist/javascripts/app.js
vendored
319
dist/javascripts/app.js
vendored
File diff suppressed because one or more lines are too long
2
dist/javascripts/app.js.map
vendored
2
dist/javascripts/app.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user