mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 23:13:04 +00:00
Merge branch 'master' into clean-relationships-in-submission
This commit is contained in:
@@ -3,7 +3,14 @@ import { HttpHeaders } from '@angular/common/http';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
import { Observable, of as observableOf, Subscription, timer as observableTimer } from 'rxjs';
|
||||
import { catchError, distinctUntilChanged, filter, find, first, map, startWith } from 'rxjs/operators';
|
||||
import {
|
||||
catchError, concatMap,
|
||||
distinctUntilChanged,
|
||||
filter,
|
||||
find,
|
||||
map,
|
||||
startWith, take, tap
|
||||
} from 'rxjs/operators';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
@@ -38,7 +45,13 @@ import { WorkspaceitemSectionsObject } from '../core/submission/models/workspace
|
||||
import { RemoteData } from '../core/data/remote-data';
|
||||
import { ErrorResponse } from '../core/cache/response.models';
|
||||
import { RemoteDataError } from '../core/data/remote-data-error';
|
||||
import { createFailedRemoteDataObject$, createSuccessfulRemoteDataObject } from '../shared/testing/utils';
|
||||
import {
|
||||
createFailedRemoteDataObject$,
|
||||
createSuccessfulRemoteDataObject,
|
||||
createSuccessfulRemoteDataObject$
|
||||
} from '../shared/testing/utils';
|
||||
import { RequestService } from '../core/data/request.service';
|
||||
import { SearchService } from '../core/shared/search/search.service';
|
||||
|
||||
/**
|
||||
* A service that provides methods used in submission process.
|
||||
@@ -67,6 +80,8 @@ export class SubmissionService {
|
||||
* @param {RouteService} routeService
|
||||
* @param {Store<SubmissionState>} store
|
||||
* @param {TranslateService} translate
|
||||
* @param {SearchService} searchService
|
||||
* @param {RequestService} requestService
|
||||
*/
|
||||
constructor(@Inject(GLOBAL_CONFIG) protected EnvConfig: GlobalConfig,
|
||||
protected notificationsService: NotificationsService,
|
||||
@@ -74,7 +89,9 @@ export class SubmissionService {
|
||||
protected router: Router,
|
||||
protected routeService: RouteService,
|
||||
protected store: Store<SubmissionState>,
|
||||
protected translate: TranslateService) {
|
||||
protected translate: TranslateService,
|
||||
protected searchService: SearchService,
|
||||
protected requestService: RequestService) {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -445,16 +462,23 @@ export class SubmissionService {
|
||||
* Redirect to MyDspace page
|
||||
*/
|
||||
redirectToMyDSpace() {
|
||||
this.routeService.getPreviousUrl().pipe(
|
||||
first()
|
||||
).subscribe((previousUrl: string) => {
|
||||
if (isEmpty(previousUrl) || !previousUrl.startsWith('/mydspace')) {
|
||||
this.router.navigate(['/mydspace']);
|
||||
} else {
|
||||
this.router.navigateByUrl(previousUrl);
|
||||
}
|
||||
});
|
||||
|
||||
// This assures that the cache is empty before redirecting to mydspace.
|
||||
// See https://github.com/DSpace/dspace-angular/pull/468
|
||||
this.searchService.getEndpoint().pipe(
|
||||
take(1),
|
||||
tap((url) => this.requestService.removeByHrefSubstring(url)),
|
||||
// Now, do redirect.
|
||||
concatMap(
|
||||
() => this.routeService.getPreviousUrl().pipe(
|
||||
take(1),
|
||||
tap((previousUrl) => {
|
||||
if (isEmpty(previousUrl) || !previousUrl.startsWith('/mydspace')) {
|
||||
this.router.navigate(['/mydspace']);
|
||||
} else {
|
||||
this.router.navigateByUrl(previousUrl);
|
||||
}
|
||||
})))
|
||||
).subscribe();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user