Merge pull request #6105 from tsiegleauq/limit-filter-update-on-autoupdate

Limit pushing of filter updates in filter service
This commit is contained in:
Emanuel Schütze 2021-06-07 15:21:03 +02:00 committed by GitHub
commit 1daee9c6d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,5 @@
import { BehaviorSubject, Observable, Subscription } from 'rxjs';
import { distinctUntilChanged } from 'rxjs/operators';
import { BaseModel } from 'app/shared/models/base/base-model';
import { BaseRepository } from '../repositories/base-repository';
@ -182,10 +183,23 @@ export abstract class BaseFilterListService<V extends BaseViewModel> {
this.inputDataSubscription.unsubscribe();
this.inputDataSubscription = null;
}
this.inputDataSubscription = inputData.subscribe(data => {
this.inputData = data;
this.updateFilteredData();
});
this.inputDataSubscription = inputData
/**
* Every autoupdate pushes data here.
* Not entirely sure why this happens.
* However, we are only concerned about changes to our
* current moddels, so compare the changes should
* limit the updating of filters
*/
.pipe(
distinctUntilChanged((curr, prev) => {
return curr.length === prev.length && curr.every((v, i) => v === prev[i]);
})
)
.subscribe(data => {
this.inputData = data;
this.updateFilteredData();
});
}
/**