@@ -75,18 +75,14 @@ function ControllerInstance(
7575 // watch for deployed/started/stopped instance
7676 // all watches necessary, updateDisplayedTabs expectst to be invoked
7777 // after fetching instance, fetching container, and cointainer start
78- var containerWatch ;
79- $scope . $watch ( 'dataInstance.data.instance' , handleInstance ) ;
80- function handleInstance ( instance ) {
81- if ( ! instance ) { return ; } // instance still being fetched
82- containerWatch = $scope . $watch ( 'dataInstance.data.instance.containers.models[0]' , handleContainer ) ;
83- }
78+ var containerWatch =
79+ $scope . $watch ( 'dataInstance.data.instance.containers.models[0]' , handleContainer ) ;
80+
8481 function handleContainer ( container ) {
8582 if ( ! container ) {
8683 buildLogsOnly ( ) ;
8784 }
8885 else { // handles both container.error and container.dockerContainer states
89- containerWatch ( ) ; // once, got container
9086 $scope . $watch ( 'dataInstance.data.instance.containers.models[0].attrs.inspect.State.Running' , displayTabsForContainerState ) ; // once
9187 }
9288 }
@@ -140,6 +136,10 @@ function ControllerInstance(
140136 displayTabsForContainerState ( keypather . get ( container , 'running()' ) ) ;
141137 }
142138
139+ $scope . $on ( '$destroy' , function ( ) {
140+ containerWatch ( ) ;
141+ } ) ;
142+
143143 function buildLogsOnly ( ) {
144144 data . openItems . reset ( [ ] ) ;
145145 // Set to true if we see the instance in an undeployed state
0 commit comments