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;
|
||||
}
|
||||
|
||||
setUserPrefValue(key: WebPrefKey, value: any, sync = false) {
|
||||
this.application!.changeItem(
|
||||
async setUserPrefValue(key: WebPrefKey, value: any, sync = false) {
|
||||
await this.application!.changeItem(
|
||||
this.userPreferences.uuid,
|
||||
(m) => {
|
||||
const mutator = m as UserPrefsMutator;
|
||||
|
||||
@@ -477,7 +477,7 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
|
||||
}
|
||||
if (this.editor.isTemplateNote) {
|
||||
await this.editor.insertTemplatedNote();
|
||||
if (this.appState.selectedTag) {
|
||||
if (this.appState.selectedTag?.isSmartTag() === false) {
|
||||
await this.application.changeItem(
|
||||
this.appState.selectedTag!.uuid,
|
||||
(mutator) => {
|
||||
@@ -879,15 +879,15 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
|
||||
this.reloadTagsString();
|
||||
}
|
||||
|
||||
onPanelResizeFinish(width: number, left: number, isMaxWidth: boolean) {
|
||||
async onPanelResizeFinish(width: number, left: number, isMaxWidth: boolean) {
|
||||
if (isMaxWidth) {
|
||||
this.application.getPrefsService().setUserPrefValue(
|
||||
await this.application.getPrefsService().setUserPrefValue(
|
||||
WebPrefKey.EditorWidth,
|
||||
null
|
||||
);
|
||||
} else {
|
||||
if (width !== undefined && width !== null) {
|
||||
this.application.getPrefsService().setUserPrefValue(
|
||||
await this.application.getPrefsService().setUserPrefValue(
|
||||
WebPrefKey.EditorWidth,
|
||||
width
|
||||
);
|
||||
@@ -895,7 +895,7 @@ class EditorViewCtrl extends PureViewCtrl implements EditorViewScope {
|
||||
}
|
||||
}
|
||||
if (left !== undefined && left !== null) {
|
||||
this.application.getPrefsService().setUserPrefValue(
|
||||
await this.application.getPrefsService().setUserPrefValue(
|
||||
WebPrefKey.EditorLeft,
|
||||
left
|
||||
);
|
||||
|
||||
@@ -400,9 +400,9 @@ class NotesViewCtrl extends PureViewCtrl {
|
||||
) {
|
||||
this.application!.getPrefsService().setUserPrefValue(
|
||||
WebPrefKey.NotesPanelWidth,
|
||||
newWidth
|
||||
newWidth,
|
||||
true
|
||||
);
|
||||
this.application!.getPrefsService().syncUserPreferences();
|
||||
this.application!.getAppState().panelDidResize(
|
||||
PANEL_NAME_NOTES,
|
||||
isCollapsed
|
||||
@@ -563,7 +563,7 @@ class NotesViewCtrl extends PureViewCtrl {
|
||||
const note = this.getFirstNonProtectedNote();
|
||||
if (note) {
|
||||
this.selectNote(note);
|
||||
} else if (!this.appState.selectedTag|| !this.appState.selectedTag.isSmartTag()) {
|
||||
} else if (!this.appState.selectedTag || !this.appState.selectedTag.isSmartTag()) {
|
||||
this.createPlaceholderNote();
|
||||
} else {
|
||||
this.appState.closeActiveEditor();
|
||||
@@ -624,8 +624,11 @@ class NotesViewCtrl extends PureViewCtrl {
|
||||
}
|
||||
|
||||
toggleWebPrefKey(key: WebPrefKey) {
|
||||
this.application!.getPrefsService().setUserPrefValue(key, !this.state[key]);
|
||||
this.application!.getPrefsService().syncUserPreferences();
|
||||
this.application!.getPrefsService().setUserPrefValue(
|
||||
key,
|
||||
!this.state[key],
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
selectedSortByCreated() {
|
||||
@@ -644,17 +647,17 @@ class NotesViewCtrl extends PureViewCtrl {
|
||||
this.selectedMenuItem();
|
||||
this.application!.getPrefsService().setUserPrefValue(
|
||||
WebPrefKey.SortNotesReverse,
|
||||
!this.getState().sortReverse
|
||||
!this.getState().sortReverse,
|
||||
true
|
||||
);
|
||||
this.application!.getPrefsService().syncUserPreferences();
|
||||
}
|
||||
|
||||
setSortBy(type: NoteSortKey) {
|
||||
this.application!.getPrefsService().setUserPrefValue(
|
||||
WebPrefKey.SortNotesBy,
|
||||
type
|
||||
type,
|
||||
true
|
||||
);
|
||||
this.application!.getPrefsService().syncUserPreferences();
|
||||
}
|
||||
|
||||
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