Skip to content

Commit ecbaf97

Browse files
committed
fix by review
1 parent 86e193c commit ecbaf97

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

packages/devextreme/js/__internal/grids/tree_list/data_source_adapter/m_data_source_adapter.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import treeListCore from '../m_core';
1717
const { queryByOptions } = storeHelper;
1818

1919
const DEFAULT_KEY_EXPRESSION = 'id';
20-
const ERROR_MESSAGE = 'Operation cancelled due to operationId mismatch (possible race condition)';
2120

2221
const isFullBranchFilterMode = (that) => that.option('filterMode') === 'fullBranch';
2322

@@ -378,15 +377,19 @@ export class DataSourceAdapterTreeList extends DataSourceAdapter {
378377
};
379378
}
380379

381-
private _loadParentsOrChildren(data, options, needChildren?) {
382-
if (options.operationId !== undefined
380+
private _isOperationIdOutdated(operationId) {
381+
return operationId !== undefined
383382
&& this._lastOperationId !== undefined
384-
&& options.operationId !== this._lastOperationId) {
385-
this._dataSource.cancel(options.operationId); // Cancel the request
383+
&& operationId !== this._lastOperationId;
384+
}
385+
386+
private _loadParentsOrChildren(data, options, needChildren?) {
387+
if (this._isOperationIdOutdated(options.operationId)) {
388+
this._dataSource.cancel(options.operationId);
386389
// @ts-expect-error
387390
const rejectedDeferred = new Deferred();
388-
rejectedDeferred.reject(new Error(ERROR_MESSAGE));
389-
return rejectedDeferred; // Return rejected Deferred
391+
rejectedDeferred.reject();
392+
return rejectedDeferred;
390393
}
391394

392395
let filter;
@@ -446,11 +449,9 @@ export class DataSourceAdapterTreeList extends DataSourceAdapter {
446449
const store = options.fullData ? new ArrayStore(options.fullData) : this._dataSource.store();
447450

448451
this.loadFromStore(loadOptions, store).done((loadedData) => {
449-
if (options.operationId !== undefined
450-
&& this._lastOperationId !== undefined
451-
&& options.operationId !== this._lastOperationId) {
452+
if (this._isOperationIdOutdated(options.operationId)) {
452453
d.reject();
453-
return; // Ignore outdated result
454+
return;
454455
}
455456

456457
if (loadedData.length) {

0 commit comments

Comments
 (0)