From c58c5e47b2a2cdc3604ec4ea526fcd0f68edf69c Mon Sep 17 00:00:00 2001 From: Baptiste Grob <60621355+baptiste-grob@users.noreply.github.com> Date: Wed, 18 Mar 2020 14:48:43 +0100 Subject: [PATCH] Fix component reloading after destruction --- app/assets/javascripts/directives/views/componentView.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/assets/javascripts/directives/views/componentView.js b/app/assets/javascripts/directives/views/componentView.js index 88a460e75..5be36b3fe 100644 --- a/app/assets/javascripts/directives/views/componentView.js +++ b/app/assets/javascripts/directives/views/componentView.js @@ -24,6 +24,7 @@ class ComponentViewCtrl { this.desktopManager = desktopManager; this.componentManager = componentManager; this.componentValid = true; + this.destroyed = false; $scope.$watch('ctrl.component', (component, prevComponent) => { this.componentValueDidSet(component, prevComponent); @@ -32,6 +33,7 @@ class ComponentViewCtrl { this.reloadStatus(false); }); $scope.$on('$destroy', () => { + this.destroyed = true; this.destroy(); }); } @@ -92,6 +94,7 @@ class ComponentViewCtrl { async reloadComponent() { this.componentValid = false; await this.componentManager.reloadComponent(this.component); + if (this.destroyed) return; this.reloadStatus(); }