diff --git a/app/assets/javascripts/app/services/componentManager.js b/app/assets/javascripts/app/services/componentManager.js index 7dcfc79e4..37c23eeb4 100644 --- a/app/assets/javascripts/app/services/componentManager.js +++ b/app/assets/javascripts/app/services/componentManager.js @@ -808,6 +808,8 @@ class ComponentManager { } }); this.postActiveThemeToComponent(component); + + this.desktopManager.notifyComponentActivation(component); } /* Performs func in timeout, but syncronously, if used `await waitTimeout` */ diff --git a/app/assets/javascripts/app/services/desktopManager.js b/app/assets/javascripts/app/services/desktopManager.js index 23612e64f..838f455ea 100644 --- a/app/assets/javascripts/app/services/desktopManager.js +++ b/app/assets/javascripts/app/services/desktopManager.js @@ -10,6 +10,7 @@ class DesktopManager { this.$rootScope = $rootScope; this.timeout = $timeout; this.updateObservers = []; + this.activationObservers = []; this.isDesktop = isDesktopApplication(); @@ -106,7 +107,26 @@ class DesktopManager { for(var observer of this.updateObservers) { observer.callback(component); } - }) + }); + } + + desktop_registerActivationObserver(callback) { + var observer = {id: Math.random, callback: callback}; + this.activationObservers.push(observer); + return observer; + } + + desktop_deregisterActivationObserver(observer) { + _.pull(this.activationObservers, observer); + } + + /* Notify observers that a component has been registered/activated */ + notifyComponentActivation(component) { + this.timeout(() => { + for(var observer of this.activationObservers) { + observer.callback(component); + } + }); } /* Used to resolve "sn://" */