@@ -19,7 +19,7 @@ import {PLOT2D, DEFAULT_PLOT2D_VIEWER_ID, dispatchAddViewerItems, dispatchRemove
19
19
*/
20
20
export function * syncCharts ( ) {
21
21
while ( true ) {
22
- const action = yield take ( [ ChartsCntlr . CHART_ADD , ChartsCntlr . CHART_MOUNTED , ChartsCntlr . CHART_REMOVE , TablesCntlr . TBL_RESULTS_ACTIVE , TablesCntlr . TABLE_LOADED ] ) ;
22
+ const action = yield take ( [ ChartsCntlr . CHART_ADD , ChartsCntlr . CHART_MOUNTED , ChartsCntlr . CHART_REMOVE , TablesCntlr . TABLE_LOADED ] ) ;
23
23
switch ( action . type ) {
24
24
case ChartsCntlr . CHART_ADD :
25
25
case ChartsCntlr . CHART_MOUNTED :
@@ -60,11 +60,13 @@ export function* syncCharts() {
60
60
*/
61
61
export function * syncChartViewer ( ) {
62
62
while ( true ) {
63
- const action = yield take ( [ ChartsCntlr . CHART_ADD , TablesCntlr . TBL_RESULTS_ACTIVE ] ) ;
63
+ const action = yield take ( [ ChartsCntlr . CHART_ADD , TablesCntlr . TBL_RESULTS_ACTIVE , TablesCntlr . TABLE_REMOVE ] ) ;
64
64
switch ( action . type ) {
65
65
case ChartsCntlr . CHART_ADD :
66
+ case TablesCntlr . TABLE_REMOVE :
66
67
case TablesCntlr . TBL_RESULTS_ACTIVE :
67
- updateDefaultViewer ( ) ;
68
+ const { chartId} = action . payload ;
69
+ updateDefaultViewer ( chartId ) ;
68
70
break ;
69
71
}
70
72
}
@@ -98,13 +100,14 @@ export function* addDefaultScatter() {
98
100
}
99
101
100
102
101
- function updateDefaultViewer ( ) {
103
+ function updateDefaultViewer ( chartId ) {
102
104
const tblId = TableUtil . getActiveTableId ( ) ;
103
105
const chartIds = [ ] ;
104
106
chartIds . push ( ...ChartsCntlr . getChartIdsInGroup ( tblId ) , ...ChartsCntlr . getChartIdsInGroup ( 'default' ) ) ;
105
107
const currentIds = getViewerItemIds ( getMultiViewRoot ( ) , DEFAULT_PLOT2D_VIEWER_ID ) ;
106
108
if ( ! isEqual ( chartIds , currentIds ) ) {
107
- dispatchUpdateCustom ( DEFAULT_PLOT2D_VIEWER_ID , { activeItemId : undefined } ) ;
109
+ const activeItemId = chartIds . includes ( chartId ) ? chartId : undefined ;
110
+ dispatchUpdateCustom ( DEFAULT_PLOT2D_VIEWER_ID , { activeItemId} ) ;
108
111
dispatchRemoveViewerItems ( DEFAULT_PLOT2D_VIEWER_ID , currentIds ) ;
109
112
dispatchAddViewerItems ( DEFAULT_PLOT2D_VIEWER_ID , chartIds , PLOT2D ) ;
110
113
}
0 commit comments