mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
127655: Fix submission infinite loading
This commit is contained in:
@@ -23,6 +23,23 @@ import { RemoteData } from '../data/remote-data';
|
||||
import { SubmissionResponse } from './submission-response.model';
|
||||
import { RestRequest } from '../data/rest-request.model';
|
||||
|
||||
/**
|
||||
* Retrieve the first emitting payload's dataDefinition, or throw an error if the request failed
|
||||
*/
|
||||
export const getFirstDataDefinition = () =>
|
||||
(source: Observable<RemoteData<SubmissionResponse>>): Observable<SubmitDataResponseDefinitionObject> =>
|
||||
source.pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
map((response: RemoteData<SubmissionResponse>) => {
|
||||
if (response.hasFailed) {
|
||||
throw new Error(response.errorMessage);
|
||||
} else {
|
||||
return hasValue(response.payload) ? response.payload.dataDefinition : response.payload;
|
||||
}
|
||||
}),
|
||||
distinctUntilChanged(),
|
||||
);
|
||||
|
||||
/**
|
||||
* The service handling all submission REST requests
|
||||
*/
|
||||
@@ -46,15 +63,7 @@ export class SubmissionRestService {
|
||||
*/
|
||||
protected fetchRequest(requestId: string): Observable<SubmitDataResponseDefinitionObject> {
|
||||
return this.rdbService.buildFromRequestUUID<SubmissionResponse>(requestId).pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
map((response: RemoteData<SubmissionResponse>) => {
|
||||
if (response.hasFailed) {
|
||||
throw new Error(response.errorMessage);
|
||||
} else {
|
||||
return hasValue(response.payload) ? response.payload.dataDefinition : response.payload;
|
||||
}
|
||||
}),
|
||||
distinctUntilChanged()
|
||||
getFirstDataDefinition(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -119,8 +128,9 @@ export class SubmissionRestService {
|
||||
tap((request: RestRequest) => {
|
||||
this.requestService.send(request);
|
||||
}),
|
||||
mergeMap(() => this.fetchRequest(requestId)),
|
||||
distinctUntilChanged());
|
||||
mergeMap((request) => this.rdbService.buildSingle(request.href)),
|
||||
getFirstDataDefinition(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user