Skip to content

Commit ef1e63a

Browse files
committed
fix: allow selecting new cell while info panel loads
1 parent d882c61 commit ef1e63a

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ class Browser extends DashboardView {
263263
this.fetchAggregationPanelData = this.fetchAggregationPanelData.bind(this);
264264
this.setAggregationPanelData = this.setAggregationPanelData.bind(this);
265265

266-
// Reference to cancel the ongoing info panel cloud function request
266+
// Handle for the ongoing info panel cloud function request
267267
this.currentInfoPanelQuery = null;
268268

269269
this.dataBrowserRef = React.createRef();
@@ -303,7 +303,7 @@ class Browser extends DashboardView {
303303
this.currentQuery.cancel();
304304
}
305305
if (this.currentInfoPanelQuery) {
306-
this.currentInfoPanelQuery.cancel();
306+
this.currentInfoPanelQuery.abort();
307307
this.currentInfoPanelQuery = null;
308308
}
309309
this.removeLocation();
@@ -354,7 +354,7 @@ class Browser extends DashboardView {
354354

355355
fetchAggregationPanelData(objectId, className, appId) {
356356
if (this.currentInfoPanelQuery) {
357-
this.currentInfoPanelQuery.cancel();
357+
this.currentInfoPanelQuery.abort();
358358
this.currentInfoPanelQuery = null;
359359
}
360360

@@ -365,18 +365,25 @@ class Browser extends DashboardView {
365365
const params = {
366366
object: Parse.Object.extend(className).createWithoutData(objectId).toPointer(),
367367
};
368+
let requestTask;
368369
const options = {
369370
useMasterKey: true,
371+
requestTask: task => {
372+
requestTask = task;
373+
},
370374
};
371375
const appName = this.props.params.appId;
372376
const cloudCodeFunction =
373377
this.state.classwiseCloudFunctions[`${appId}${appName}`]?.[className][0].cloudCodeFunction;
374378

375379
const promise = Parse.Cloud.run(cloudCodeFunction, params, options);
376-
this.currentInfoPanelQuery = promise;
380+
this.currentInfoPanelQuery = {
381+
abort: () => requestTask?.abort(),
382+
promise,
383+
};
377384
promise.then(
378385
result => {
379-
if (this.currentInfoPanelQuery !== promise) {
386+
if (this.currentInfoPanelQuery?.promise !== promise) {
380387
return;
381388
}
382389
if (result && result.panel && result.panel && result.panel.segments) {
@@ -390,7 +397,7 @@ class Browser extends DashboardView {
390397
}
391398
},
392399
error => {
393-
if (this.currentInfoPanelQuery !== promise) {
400+
if (this.currentInfoPanelQuery?.promise !== promise) {
394401
return;
395402
}
396403
this.setState({
@@ -400,7 +407,7 @@ class Browser extends DashboardView {
400407
this.showNote(this.state.errorAggregatedData, true);
401408
}
402409
).finally(() => {
403-
if (this.currentInfoPanelQuery === promise) {
410+
if (this.currentInfoPanelQuery?.promise === promise) {
404411
this.currentInfoPanelQuery = null;
405412
}
406413
});

0 commit comments

Comments
 (0)