fix: remove app observer on controller deinit
This commit is contained in:
@@ -55,6 +55,7 @@ class FooterViewCtrl extends PureViewCtrl {
|
|||||||
public newUpdateAvailable = false
|
public newUpdateAvailable = false
|
||||||
public dockShortcuts: DockShortcut[] = []
|
public dockShortcuts: DockShortcut[] = []
|
||||||
public roomShowState: Partial<Record<string, boolean>> = {}
|
public roomShowState: Partial<Record<string, boolean>> = {}
|
||||||
|
private observerRemovers: Array<() => void> = [];
|
||||||
|
|
||||||
/* @ngInject */
|
/* @ngInject */
|
||||||
constructor(
|
constructor(
|
||||||
@@ -69,6 +70,8 @@ class FooterViewCtrl extends PureViewCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deinit() {
|
deinit() {
|
||||||
|
for (const remove of this.observerRemovers) remove();
|
||||||
|
this.observerRemovers.length = 0;
|
||||||
this.rooms.length = 0;
|
this.rooms.length = 0;
|
||||||
this.themesWithIcons.length = 0;
|
this.themesWithIcons.length = 0;
|
||||||
this.unregisterComponent();
|
this.unregisterComponent();
|
||||||
@@ -219,7 +222,7 @@ class FooterViewCtrl extends PureViewCtrl {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
this.application!.streamItems(
|
this.observerRemovers.push(this.application!.streamItems(
|
||||||
ContentType.Component,
|
ContentType.Component,
|
||||||
async () => {
|
async () => {
|
||||||
const components = this.application!.getItems(ContentType.Component) as SNComponent[];
|
const components = this.application!.getItems(ContentType.Component) as SNComponent[];
|
||||||
@@ -231,16 +234,16 @@ class FooterViewCtrl extends PureViewCtrl {
|
|||||||
this.reloadExtendedData();
|
this.reloadExtendedData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
));
|
||||||
|
|
||||||
this.application!.streamItems(
|
this.observerRemovers.push(this.application!.streamItems(
|
||||||
ContentType.Theme,
|
ContentType.Theme,
|
||||||
async () => {
|
async () => {
|
||||||
const themes = this.application!.getDisplayableItems(ContentType.Theme) as SNTheme[];
|
const themes = this.application!.getDisplayableItems(ContentType.Theme) as SNTheme[];
|
||||||
this.themesWithIcons = themes;
|
this.themesWithIcons = themes;
|
||||||
this.reloadDockShortcuts();
|
this.reloadDockShortcuts();
|
||||||
}
|
}
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
registerComponentHandler() {
|
registerComponentHandler() {
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ class NotesViewCtrl extends PureViewCtrl {
|
|||||||
private searchKeyObserver: any
|
private searchKeyObserver: any
|
||||||
private noteFlags: Partial<Record<UuidString, NoteFlag[]>> = {}
|
private noteFlags: Partial<Record<UuidString, NoteFlag[]>> = {}
|
||||||
private unsubEditorChange: any
|
private unsubEditorChange: any
|
||||||
|
private removeObservers: Array<() => void> = [];
|
||||||
|
|
||||||
/* @ngInject */
|
/* @ngInject */
|
||||||
constructor($timeout: ng.ITimeoutService, ) {
|
constructor($timeout: ng.ITimeoutService, ) {
|
||||||
@@ -89,6 +90,8 @@ class NotesViewCtrl extends PureViewCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deinit() {
|
deinit() {
|
||||||
|
for (const remove of this.removeObservers) remove();
|
||||||
|
this.removeObservers.length = 0;
|
||||||
this.panelPuppet!.onReady = undefined;
|
this.panelPuppet!.onReady = undefined;
|
||||||
this.panelPuppet = undefined;
|
this.panelPuppet = undefined;
|
||||||
window.removeEventListener('resize', this.onWindowResize, true);
|
window.removeEventListener('resize', this.onWindowResize, true);
|
||||||
@@ -198,7 +201,7 @@ class NotesViewCtrl extends PureViewCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
streamNotesAndTags() {
|
streamNotesAndTags() {
|
||||||
this.application!.streamItems(
|
this.removeObservers.push(this.application!.streamItems(
|
||||||
[ContentType.Note],
|
[ContentType.Note],
|
||||||
async (items) => {
|
async (items) => {
|
||||||
const notes = items as SNNote[];
|
const notes = items as SNNote[];
|
||||||
@@ -222,9 +225,9 @@ class NotesViewCtrl extends PureViewCtrl {
|
|||||||
this.selectFirstNote();
|
this.selectFirstNote();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
));
|
||||||
|
|
||||||
this.application!.streamItems(
|
this.removeObservers.push(this.application!.streamItems(
|
||||||
[ContentType.Tag],
|
[ContentType.Tag],
|
||||||
async (items) => {
|
async (items) => {
|
||||||
const tags = items as SNTag[];
|
const tags = items as SNTag[];
|
||||||
@@ -236,7 +239,7 @@ class NotesViewCtrl extends PureViewCtrl {
|
|||||||
this.reloadPanelTitle();
|
this.reloadPanelTitle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
async selectNote(note: SNNote) {
|
async selectNote(note: SNNote) {
|
||||||
|
|||||||
Reference in New Issue
Block a user