sea-chart 1.1.40 → 1.1.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,6 +3,14 @@ class ConcurrencyManager {
|
|
|
3
3
|
this.concurrentCount = concurrentCount;
|
|
4
4
|
this.requestList = [];
|
|
5
5
|
this.queue = [];
|
|
6
|
+
this.currentPageId = null;
|
|
7
|
+
}
|
|
8
|
+
setCurrentPageId(pageId) {
|
|
9
|
+
this.currentPageId = pageId;
|
|
10
|
+
}
|
|
11
|
+
clearPendingRequests() {
|
|
12
|
+
this.requestList = [];
|
|
13
|
+
this.queue = [];
|
|
6
14
|
}
|
|
7
15
|
applyRequest(req) {
|
|
8
16
|
if (this.requestList.length < this.concurrentCount) {
|
package/dist/view/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import { isEqual } from 'lodash-es';
|
|
5
|
+
import shallowEqual from 'shallowequal';
|
|
5
6
|
import context from '../context';
|
|
6
7
|
import intl from '../intl';
|
|
7
8
|
import eventBus from '../utils/event-bus';
|
|
@@ -9,6 +10,7 @@ import { Loading } from '../components';
|
|
|
9
10
|
import { ChartUtils, BaseUtils } from '../utils/chart-utils';
|
|
10
11
|
import { DEFAULT_LANG, THEME_NAME_MAP } from '../constants';
|
|
11
12
|
import { CommonEventTypes } from '../constants/common-constants';
|
|
13
|
+
import concurrencyManager from '../utils/concurrency-manager';
|
|
12
14
|
import Wrapper from './wrapper';
|
|
13
15
|
import Title from './title';
|
|
14
16
|
import './index.css';
|
|
@@ -134,9 +136,17 @@ class View extends React.PureComponent {
|
|
|
134
136
|
const {
|
|
135
137
|
isCalculateByView,
|
|
136
138
|
autoRefresh,
|
|
137
|
-
refreshInterval
|
|
139
|
+
refreshInterval,
|
|
140
|
+
pageId
|
|
138
141
|
} = this.props;
|
|
139
142
|
this.unsubscribeReFreshChart = eventBus.subscribe(CommonEventTypes.REFRESH_CHARTS, this.refreshChart);
|
|
143
|
+
|
|
144
|
+
// pageId was used to determine whether the page has changed
|
|
145
|
+
// cancel all the cached request if pageId changed
|
|
146
|
+
if (pageId && concurrencyManager.currentPageId !== pageId) {
|
|
147
|
+
concurrencyManager.clearPendingRequests();
|
|
148
|
+
concurrencyManager.setCurrentPageId(pageId);
|
|
149
|
+
}
|
|
140
150
|
if (((_window$app = window.app) === null || _window$app === void 0 ? void 0 : _window$app.eventBus) && isCalculateByView) {
|
|
141
151
|
window.app.eventBus.subscribe(CommonEventTypes.EXPAND_ROW_UPDATED, this.handleModifyRecord);
|
|
142
152
|
window.app.eventBus.subscribe(CommonEventTypes.EXPAND_ROW_DELETED, this.handleDeleteRecord);
|
|
@@ -170,7 +180,8 @@ class View extends React.PureComponent {
|
|
|
170
180
|
hasUnSaved: nextUnSaved,
|
|
171
181
|
version: nextVersion,
|
|
172
182
|
autoRefresh,
|
|
173
|
-
refreshInterval
|
|
183
|
+
refreshInterval,
|
|
184
|
+
pageId
|
|
174
185
|
} = nextProps;
|
|
175
186
|
const {
|
|
176
187
|
data
|
|
@@ -187,6 +198,13 @@ class View extends React.PureComponent {
|
|
|
187
198
|
}
|
|
188
199
|
context.api = this.props.api;
|
|
189
200
|
|
|
201
|
+
// pageId was used to determine whether the page has changed
|
|
202
|
+
// cancel all the cached request if pageId changed
|
|
203
|
+
if (pageId && concurrencyManager.currentPageId !== pageId) {
|
|
204
|
+
concurrencyManager.clearPendingRequests();
|
|
205
|
+
concurrencyManager.setCurrentPageId(pageId);
|
|
206
|
+
}
|
|
207
|
+
|
|
190
208
|
// universal-apps will not trigger calculation of the chart before the chart config saved
|
|
191
209
|
// after saved, hasUnSaved was set to false, then trigger calculation
|
|
192
210
|
const needCalc = hasUnSaved === true && nextUnSaved === false;
|
|
@@ -196,17 +214,7 @@ class View extends React.PureComponent {
|
|
|
196
214
|
}
|
|
197
215
|
|
|
198
216
|
// version was used to dectect table change in big screen plugin
|
|
199
|
-
|
|
200
|
-
config,
|
|
201
|
-
style_config
|
|
202
|
-
} = chart;
|
|
203
|
-
const {
|
|
204
|
-
config: oldConfig,
|
|
205
|
-
style_config: oldStyleConfig
|
|
206
|
-
} = oldChart;
|
|
207
|
-
const isConfigUnchange = isEqual(config, oldConfig) && version === nextVersion;
|
|
208
|
-
const isStyleUnchange = isEqual(style_config, oldStyleConfig);
|
|
209
|
-
if (isConfigUnchange && isStyleUnchange) return;
|
|
217
|
+
if (shallowEqual(chart, oldChart) && version === nextVersion) return;
|
|
210
218
|
this.setState({
|
|
211
219
|
isCalculated: false
|
|
212
220
|
}, () => {
|