mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-14 21:43:04 +00:00
65717: Fix reloading lists on viewing more while still preventing unwanted initializes
This commit is contained in:
@@ -14,6 +14,7 @@ import { BundleDataService } from '../../../../core/data/bundle-data.service';
|
|||||||
import { PaginatedSearchOptions } from '../../../../+search-page/paginated-search-options.model';
|
import { PaginatedSearchOptions } from '../../../../+search-page/paginated-search-options.model';
|
||||||
import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject';
|
import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject';
|
||||||
import { combineLatest as observableCombineLatest } from 'rxjs';
|
import { combineLatest as observableCombineLatest } from 'rxjs';
|
||||||
|
import { hasNoValue } from '../../../../shared/empty.util';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-item-edit-bitstream-bundle',
|
selector: 'ds-item-edit-bitstream-bundle',
|
||||||
@@ -76,6 +77,12 @@ export class ItemEditBitstreamBundleComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
isLoadingMore$: Observable<boolean>;
|
isLoadingMore$: Observable<boolean>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What size were the object updates last initialized with?
|
||||||
|
* Used to check if the object updates need to be re-initialized when loading more bitstreams
|
||||||
|
*/
|
||||||
|
lastInitializedWithSize: number;
|
||||||
|
|
||||||
constructor(private objectUpdatesService: ObjectUpdatesService,
|
constructor(private objectUpdatesService: ObjectUpdatesService,
|
||||||
private bundleService: BundleDataService,
|
private bundleService: BundleDataService,
|
||||||
private viewContainerRef: ViewContainerRef) {
|
private viewContainerRef: ViewContainerRef) {
|
||||||
@@ -88,8 +95,12 @@ export class ItemEditBitstreamBundleComponent implements OnInit {
|
|||||||
);
|
);
|
||||||
this.updates$ = this.bitstreamsRD$.pipe(
|
this.updates$ = this.bitstreamsRD$.pipe(
|
||||||
toBitstreamsArray(),
|
toBitstreamsArray(),
|
||||||
tap((bitstreams: Bitstream[]) => this.objectUpdatesService.initialize(this.bundle.self, bitstreams, new Date(), true)),
|
tap((bitstreams: Bitstream[]) => {
|
||||||
take(1),
|
if (hasNoValue(this.lastInitializedWithSize) || this.currentSize$.value !== this.lastInitializedWithSize) {
|
||||||
|
this.objectUpdatesService.initialize(this.bundle.self, bitstreams, new Date(), true);
|
||||||
|
this.lastInitializedWithSize = this.currentSize$.value;
|
||||||
|
}
|
||||||
|
}),
|
||||||
switchMap((bitstreams: Bitstream[]) => this.objectUpdatesService.getFieldUpdatesByCustomOrder(this.bundle.self, bitstreams))
|
switchMap((bitstreams: Bitstream[]) => this.objectUpdatesService.getFieldUpdatesByCustomOrder(this.bundle.self, bitstreams))
|
||||||
);
|
);
|
||||||
this.isLoadingMore$ = observableCombineLatest(this.currentSize$, this.bitstreamsRD$).pipe(
|
this.isLoadingMore$ = observableCombineLatest(this.currentSize$, this.bitstreamsRD$).pipe(
|
||||||
|
Reference in New Issue
Block a user