Skip to content

Commit 7765962

Browse files
committed
fix: cancel stale info panel requests
1 parent 685e11c commit 7765962

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/dashboard/Data/Browser/Browser.react.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,6 @@ class Browser extends DashboardView {
264264
this.setAggregationPanelData = this.setAggregationPanelData.bind(this);
265265

266266
// Reference to cancel the ongoing info panel cloud function request
267-
this.currentInfoPanelRequest = null;
268267
this.currentInfoPanelQuery = null;
269268

270269
this.dataBrowserRef = React.createRef();
@@ -303,8 +302,8 @@ class Browser extends DashboardView {
303302
if (this.currentQuery) {
304303
this.currentQuery.cancel();
305304
}
306-
if (this.currentInfoPanelRequest) {
307-
this.currentInfoPanelRequest.abort();
305+
if (this.currentInfoPanelQuery && this.currentInfoPanelQuery.abort) {
306+
this.currentInfoPanelQuery.abort();
308307
this.currentInfoPanelQuery = null;
309308
}
310309
this.removeLocation();
@@ -354,9 +353,8 @@ class Browser extends DashboardView {
354353
}
355354

356355
fetchAggregationPanelData(objectId, className, appId) {
357-
if (this.currentInfoPanelRequest) {
358-
this.currentInfoPanelRequest.abort();
359-
this.currentInfoPanelRequest = null;
356+
if (this.currentInfoPanelQuery && this.currentInfoPanelQuery.abort) {
357+
this.currentInfoPanelQuery.abort();
360358
this.currentInfoPanelQuery = null;
361359
}
362360

@@ -367,17 +365,19 @@ class Browser extends DashboardView {
367365
const params = {
368366
object: Parse.Object.extend(className).createWithoutData(objectId).toPointer(),
369367
};
368+
let xhr;
370369
const options = {
371370
useMasterKey: true,
372-
requestTask: xhr => {
373-
this.currentInfoPanelRequest = xhr;
371+
requestTask: req => {
372+
xhr = req;
374373
},
375374
};
376375
const appName = this.props.params.appId;
377376
const cloudCodeFunction =
378377
this.state.classwiseCloudFunctions[`${appId}${appName}`]?.[className][0].cloudCodeFunction;
379378

380379
const promise = Parse.Cloud.run(cloudCodeFunction, params, options);
380+
promise.abort = () => xhr && xhr.abort();
381381
this.currentInfoPanelQuery = promise;
382382
promise.then(
383383
result => {
@@ -406,7 +406,6 @@ class Browser extends DashboardView {
406406
}
407407
).finally(() => {
408408
if (this.currentInfoPanelQuery === promise) {
409-
this.currentInfoPanelRequest = null;
410409
this.currentInfoPanelQuery = null;
411410
}
412411
});

0 commit comments

Comments
 (0)