11import { RemoteData } from '../../../core/data/remote-data' ;
22import { NoContent } from '../../../core/shared/NoContent.model' ;
33import { FeedbackDataService } from '../../../core/feedback/feedback-data.service' ;
4- import { Component , OnInit } from '@angular/core' ;
4+ import { Component , Inject , OnInit } from '@angular/core' ;
55import { RouteService } from '../../../core/services/route.service' ;
66import { FormBuilder , Validators } from '@angular/forms' ;
77import { NotificationsService } from '../../../shared/notifications/notifications.service' ;
@@ -10,6 +10,10 @@ import { AuthService } from '../../../core/auth/auth.service';
1010import { EPerson } from '../../../core/eperson/models/eperson.model' ;
1111import { getFirstCompletedRemoteData } from '../../../core/shared/operators' ;
1212import { Router } from '@angular/router' ;
13+ import { getHomePageRoute } from '../../../app-routing-paths' ;
14+ import { take } from 'rxjs/operators' ;
15+ import { NativeWindowRef , NativeWindowService } from '../../../core/services/window.service' ;
16+ import { URLCombiner } from '../../../core/url-combiner/url-combiner' ;
1317
1418@Component ( {
1519 selector : 'ds-feedback-form' ,
@@ -31,6 +35,7 @@ export class FeedbackFormComponent implements OnInit {
3135 } ) ;
3236
3337 constructor (
38+ @Inject ( NativeWindowService ) protected _window : NativeWindowRef ,
3439 public routeService : RouteService ,
3540 private fb : FormBuilder ,
3641 protected notificationsService : NotificationsService ,
@@ -45,17 +50,18 @@ export class FeedbackFormComponent implements OnInit {
4550 */
4651 ngOnInit ( ) {
4752
48- this . authService . getAuthenticatedUserFromStore ( ) . subscribe ( ( user : EPerson ) => {
53+ this . authService . getAuthenticatedUserFromStore ( ) . pipe ( take ( 1 ) ) . subscribe ( ( user : EPerson ) => {
4954 if ( ! ! user ) {
5055 this . feedbackForm . patchValue ( { email : user . email } ) ;
5156 }
5257 } ) ;
5358
54- this . routeService . getPreviousUrl ( ) . subscribe ( ( url : string ) => {
59+ this . routeService . getPreviousUrl ( ) . pipe ( take ( 1 ) ) . subscribe ( ( url : string ) => {
5560 if ( ! url ) {
56- url = '/home' ;
61+ url = getHomePageRoute ( ) ;
5762 }
58- this . feedbackForm . patchValue ( { page : url } ) ;
63+ const relatedUrl = new URLCombiner ( this . _window . nativeWindow . origin , url ) . toString ( ) ;
64+ this . feedbackForm . patchValue ( { page : relatedUrl } ) ;
5965 } ) ;
6066
6167 }
0 commit comments