fix: deregister stream observers on editor deinit

This commit is contained in:
Mo Bitar
2020-04-21 12:17:01 -05:00
parent 84de39375c
commit f9733f8dac
7 changed files with 318 additions and 247 deletions

View File

@@ -76,11 +76,8 @@ class NotesViewCtrl extends PureViewCtrl {
$onInit() {
super.$onInit();
angular.element(document).ready(() => {
this.reloadPreferences();
});
this.panelPuppet = {
onReady: () => this.reloadPreferences()
onReady: () => this.reloadPanelWidth()
};
this.unsubEditorChange = this.application.editorGroup.addChangeObserver(() => {
this.setNotesState({
@@ -407,9 +404,27 @@ class NotesViewCtrl extends PureViewCtrl {
WebPrefKey.NotesHideDate,
false
);
const state = this.getState();
const displayOptionsChanged = (
viewOptions.sortBy !== state.sortBy ||
viewOptions.sortReverse !== state.sortReverse ||
viewOptions.hidePinned !== state.hidePinned ||
viewOptions.showArchived !== state.showArchived
);
await this.setNotesState({
...viewOptions
});
this.reloadPanelWidth();
if (displayOptionsChanged) {
this.reloadNotesDisplayOptions();
}
await this.reloadNotes();
if (prevSortValue && prevSortValue !== sortBy) {
this.selectFirstNote();
}
}
reloadPanelWidth() {
const width = this.application!.getPrefsService().getValue(
WebPrefKey.NotesPanelWidth
);
@@ -422,11 +437,6 @@ class NotesViewCtrl extends PureViewCtrl {
);
}
}
this.reloadNotesDisplayOptions();
await this.reloadNotes();
if (prevSortValue && prevSortValue !== sortBy) {
this.selectFirstNote();
}
}
onPanelResize(