aboutsummaryrefslogtreecommitdiff
path: root/src/DevHive.Angular
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2021-01-22 19:19:47 +0200
committerSyndamia <kamen.d.mladenov@protonmail.com>2021-01-22 19:19:47 +0200
commitb24a160bbdb4df529a932b392d7c0d75013b9319 (patch)
tree389af8e73977646de206be7aa1c17ed0acd4e108 /src/DevHive.Angular
parent8a2152c98dc1c82b6476d6b8108615b2770e008a (diff)
downloadDevHive-b24a160bbdb4df529a932b392d7c0d75013b9319.tar
DevHive-b24a160bbdb4df529a932b392d7c0d75013b9319.tar.gz
DevHive-b24a160bbdb4df529a932b392d7c0d75013b9319.zip
Back buttons now go back to the previous page you were on (not the root of the website)
Diffstat (limited to 'src/DevHive.Angular')
-rw-r--r--src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.ts9
-rw-r--r--src/DevHive.Angular/src/app/components/profile/profile.component.ts9
2 files changed, 14 insertions, 4 deletions
diff --git a/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.ts b/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.ts
index d7c7ee6..0848f51 100644
--- a/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.ts
+++ b/src/DevHive.Angular/src/app/components/profile-settings/profile-settings.component.ts
@@ -1,3 +1,4 @@
+import {Location} from '@angular/common';
import {HttpErrorResponse} from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
@@ -18,7 +19,7 @@ export class ProfileSettingsComponent implements OnInit {
public user: User;
public successfulUpdate = false;
- constructor(private _router: Router, private _userService: UserService, private _fb: FormBuilder)
+ constructor(private _router: Router, private _userService: UserService, private _fb: FormBuilder, private _location: Location)
{ }
ngOnInit(): void {
@@ -107,7 +108,11 @@ export class ProfileSettingsComponent implements OnInit {
}
goBack(): void {
- this._router.navigate(['/']);
+ const currURL = this._location.path();
+ this._location.back();
+ if (this._location.path() === currURL) {
+ this.goToProfile();
+ }
}
logout(): void {
diff --git a/src/DevHive.Angular/src/app/components/profile/profile.component.ts b/src/DevHive.Angular/src/app/components/profile/profile.component.ts
index bfa3e3d..b4c42a0 100644
--- a/src/DevHive.Angular/src/app/components/profile/profile.component.ts
+++ b/src/DevHive.Angular/src/app/components/profile/profile.component.ts
@@ -4,6 +4,7 @@ import { UserService } from 'src/app/services/user.service';
import { User } from 'src/models/identity/user';
import { AppConstants } from 'src/app/app-constants.module';
import {HttpErrorResponse} from '@angular/common/http';
+import {Location} from '@angular/common';
@Component({
selector: 'app-profile',
@@ -16,7 +17,7 @@ export class ProfileComponent implements OnInit {
public dataArrived = false;
public user: User;
- constructor(private _router: Router, private _userService: UserService)
+ constructor(private _router: Router, private _userService: UserService, private _location: Location)
{ }
private setDefaultUser(): void {
@@ -65,7 +66,11 @@ export class ProfileComponent implements OnInit {
}
goBack(): void {
- this._router.navigate(['/']);
+ const currURL = this._location.path();
+ this._location.back();
+ if (this._location.path() === currURL) {
+ this._router.navigate(['/']);
+ }
}
navigateToSettings(): void {