Skip to content

Commit db864d6

Browse files
committed
net-debug: Properly unregister NodeTable and EdgeTable when unmounting.
1 parent 59ccae1 commit db864d6

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

build/app/view/netcreate/components/EdgeTable.jsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ class EdgeTable extends UNISYS.Component {
5555
sortkey: 'Relationship'
5656
};
5757

58+
this.handleDataUpdate = this.handleDataUpdate.bind(this);
59+
this.OnTemplateUpdate = this.OnTemplateUpdate.bind(this);
5860
this.onButtonClick = this.onButtonClick.bind(this);
5961
this.onToggleExpanded = this.onToggleExpanded.bind(this);
6062
this.m_FindMatchingObjsByProp = this.m_FindMatchingObjsByProp.bind(this);
@@ -71,14 +73,10 @@ class EdgeTable extends UNISYS.Component {
7173

7274
// Always make sure class methods are bind()'d before using them
7375
// as a handler, otherwise object context is lost
74-
this.OnAppStateChange('D3DATA',(data) => {
75-
this.handleDataUpdate(data);
76-
});
76+
this.OnAppStateChange('D3DATA', this.handleDataUpdate);
7777

7878
// Handle Template updates
79-
this.OnAppStateChange('TEMPLATE',(data) => {
80-
this.setState({edgePrompts: data.edgePrompts});
81-
});
79+
this.OnAppStateChange('TEMPLATE', this.OnTemplateUpdate);
8280
} // constructor
8381

8482

@@ -98,6 +96,11 @@ class EdgeTable extends UNISYS.Component {
9896
}
9997
}
10098
}
99+
}
100+
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
101+
OnTemplateUpdate(data) {
102+
this.setState({edgePrompts: data.edgePrompts});
103+
}
101104

102105

103106
/// UTILITIES /////////////////////////////////////////////////////////////////
@@ -417,6 +420,10 @@ class EdgeTable extends UNISYS.Component {
417420
// update while we were hidden.
418421
let D3DATA = this.AppState('D3DATA');
419422
this.handleDataUpdate(D3DATA);
423+
424+
componentWillUnmount() {
425+
this.AppStateChangeOff('D3DATA', this.handleDataUpdate);
426+
this.AppStateChangeOff('TEMPLATE', this.OnTemplateUpdate);
420427
}
421428

422429
displayUpdated(nodeEdge)

build/app/view/netcreate/components/NodeTable.jsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ class NodeTable extends UNISYS.Component {
5454
sortkey: 'label'
5555
};
5656

57-
this.onButtonClick = this.onButtonClick.bind(this);
57+
this.handleDataUpdate = this.handleDataUpdate.bind(this);
58+
this.OnTemplateUpdate = this.OnTemplateUpdate.bind(this);
59+
this.onButtonClick = this.onButtonClick.bind(this);
5860
this.onToggleExpanded = this.onToggleExpanded.bind(this);
5961
this.setSortKey = this.setSortKey.bind(this);
6062
this.sortSymbol = this.sortSymbol.bind(this);
@@ -66,14 +68,10 @@ class NodeTable extends UNISYS.Component {
6668

6769
// Always make sure class methods are bind()'d before using them
6870
// as a handler, otherwise object context is lost
69-
this.OnAppStateChange('D3DATA',(data) => {
70-
this.handleDataUpdate(data);
71-
});
71+
this.OnAppStateChange('D3DATA', this.handleDataUpdate);
7272

7373
// Handle Template updates
74-
this.OnAppStateChange('TEMPLATE',(data) => {
75-
this.setState({nodePrompts: data.nodePrompts});
76-
});
74+
this.OnAppStateChange('TEMPLATE', this.OnTemplateUpdate);
7775
} // constructor
7876

7977

@@ -99,6 +97,9 @@ handleDataUpdate(data) {
9997
});
10098
}
10199
}
100+
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
101+
OnTemplateUpdate(data) {
102+
this.setState({nodePrompts: data.nodePrompts});
102103
}
103104
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
104105
/*/ Build table of counts
@@ -363,6 +364,11 @@ render() {
363364
this.handleDataUpdate(D3DATA);
364365
}
365366

367+
componentWillUnmount() {
368+
this.AppStateChangeOff('D3DATA', this.handleDataUpdate);
369+
this.AppStateChangeOff('TEMPLATE', this.OnTemplateUpdate);
370+
}
371+
366372
displayUpdated(nodeEdge)
367373
{
368374
var d = new Date(nodeEdge.meta.revision > 0 ? nodeEdge.meta.updated : nodeEdge.meta.created);

0 commit comments

Comments
 (0)