Fixes
This commit is contained in:
@@ -59,7 +59,6 @@ export class AppState {
|
||||
this.registerVisibilityObservers();
|
||||
this.addAppEventObserver();
|
||||
this.streamNotesAndTags();
|
||||
|
||||
const onVisibilityChange = () => {
|
||||
const visible = document.visibilityState === "visible";
|
||||
const event = visible
|
||||
|
||||
@@ -97,7 +97,11 @@ export class WebApplication extends SNApplication {
|
||||
(this.scope! as any).application = undefined;
|
||||
this.scope!.$destroy();
|
||||
this.scope = undefined;
|
||||
super.deinit();
|
||||
/** Allow our Angular directives to be destroyed and any pending digest cycles
|
||||
* to complete before destroying the global application instance and all its services */
|
||||
setImmediate(() => {
|
||||
super.deinit();
|
||||
})
|
||||
}
|
||||
|
||||
setWebServices(services: WebServices) {
|
||||
|
||||
@@ -20,14 +20,11 @@ export class ComponentGroup {
|
||||
}
|
||||
|
||||
get componentManager() {
|
||||
return this.application.componentManager!;
|
||||
return this.application?.componentManager!;
|
||||
}
|
||||
|
||||
public deinit() {
|
||||
(this.application as any) = undefined;
|
||||
for (const component of this.allActiveComponents()) {
|
||||
this.componentManager.deregisterComponent(component.uuid);
|
||||
}
|
||||
}
|
||||
|
||||
async activateComponent(component: SNComponent) {
|
||||
@@ -50,9 +47,15 @@ export class ComponentGroup {
|
||||
return;
|
||||
}
|
||||
removeFromArray(this.activeComponents, component.uuid);
|
||||
await this.componentManager.deactivateComponent(component.uuid);
|
||||
if(notify) {
|
||||
this.notifyObservers();
|
||||
/** If this function is called as part of global application deinit (locking),
|
||||
* componentManager can be destroyed. In this case, it's harmless to not take any
|
||||
* action since the componentManager will be destroyed, and the component will
|
||||
* essentially be deregistered. */
|
||||
if(this.componentManager) {
|
||||
await this.componentManager.deactivateComponent(component.uuid);
|
||||
if(notify) {
|
||||
this.notifyObservers();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,9 @@ export class EditorGroup {
|
||||
if (this.activeEditor) {
|
||||
callback();
|
||||
}
|
||||
return () => {
|
||||
removeFromArray(this.changeObservers, callback);
|
||||
}
|
||||
}
|
||||
|
||||
private notifyObservers() {
|
||||
|
||||
Reference in New Issue
Block a user