Skip to content

Commit

Permalink
fix: deactivate themes on deinit
Browse files Browse the repository at this point in the history
  • Loading branch information
moughxyz committed Sep 25, 2020
1 parent e177dca commit 8377133
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
10 changes: 7 additions & 3 deletions app/assets/javascripts/directives/views/componentView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,15 @@ class ComponentViewCtrl implements ComponentViewScope {
}

$onDestroy() {
this.application.componentManager.onComponentIframeDestroyed(this.component.uuid);
if(this.application.componentManager) {
/** Component manager Can be destroyed already via locking */
this.application.componentManager.onComponentIframeDestroyed(this.component.uuid);
if(this.templateComponent) {
this.application.componentManager.removeTemporaryTemplateComponent(this.templateComponent);
}
}
if(this.liveComponent) {
this.liveComponent.deinit();
} else {
this.application.componentManager.removeTemporaryTemplateComponent(this.templateComponent);
}
this.cleanUpOn();
(this.cleanUpOn as any) = undefined;
Expand Down
7 changes: 6 additions & 1 deletion app/assets/javascripts/services/themeManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class ThemeManager extends ApplicationService {
}

deinit() {
this.clearAppThemeState();
this.unsubState?.();
(this.unsubState as any) = undefined;
this.activeThemes.length = 0;
Expand Down Expand Up @@ -89,10 +90,14 @@ export class ThemeManager extends ApplicationService {
})
}

private deactivateAllThemes() {
private clearAppThemeState() {
for (const uuid of this.activeThemes) {
this.deactivateTheme(uuid, false);
}
}

private deactivateAllThemes() {
this.clearAppThemeState();
this.activeThemes = [];
this.decacheThemes();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export declare class ThemeManager extends ApplicationService {
onAppStart(): Promise<void>;
private activateCachedThemes;
private registerObservers;
private clearAppThemeState;
private deactivateAllThemes;
private activateTheme;
private deactivateTheme;
Expand Down

0 comments on commit 8377133

Please sign in to comment.