From 12e2bcbbd9887ad259d346673eb6e0be70ab1a2f Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 22 Feb 2019 13:17:10 -0500 Subject: [PATCH] go back to previous url after lock --- jslib | 2 +- src/app/accounts/lock.component.ts | 11 +++++++---- src/app/app.component.ts | 3 +++ src/app/services/router.service.ts | 6 +++++- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/jslib b/jslib index 3362334d2c..2b575f0c60 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 3362334d2ce2220fb0d1af322d88c9efec37763d +Subproject commit 2b575f0c6064df6e4d8ad5ed4c76f084fcb3a898 diff --git a/src/app/accounts/lock.component.ts b/src/app/accounts/lock.component.ts index 6f34895e60..7356f8abe8 100644 --- a/src/app/accounts/lock.component.ts +++ b/src/app/accounts/lock.component.ts @@ -36,9 +36,12 @@ export class LockComponent extends BaseLockComponent { this.router.navigate(['vault']); } - const previousUrl = this.routerService.getPreviousUrl(); - if (previousUrl !== '/' && previousUrl.indexOf('lock') === -1) { - this.successRoute = previousUrl; - } + this.onSuccessfulSubmit = () => { + const previousUrl = this.routerService.getPreviousUrl(); + if (previousUrl !== '/' && previousUrl.indexOf('lock') === -1) { + this.successRoute = previousUrl; + } + this.router.navigate([this.successRoute]); + }; } } diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 8b980dc1cb..56fe0ad946 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -111,6 +111,9 @@ export class AppComponent implements OnDestroy, OnInit { this.notificationsService.updateConnection(false); this.router.navigate(['lock']); break; + case 'lockedUrl': + window.setTimeout(() => this.routerService.setPreviousUrl(message.url), 500); + break; case 'syncStarted': break; case 'syncCompleted': diff --git a/src/app/services/router.service.ts b/src/app/services/router.service.ts index b3ffd181a4..8f5e04dcb9 100644 --- a/src/app/services/router.service.ts +++ b/src/app/services/router.service.ts @@ -14,7 +14,7 @@ export class RouterService { private currentUrl: string = undefined; constructor(private router: Router, private activatedRoute: ActivatedRoute, - private titleService: Title, private i18nService: I18nService) { + private titleService: Title, i18nService: I18nService) { this.currentUrl = this.router.url; router.events.subscribe((event) => { if (event instanceof NavigationEnd) { @@ -55,4 +55,8 @@ export class RouterService { getPreviousUrl() { return this.previousUrl; } + + setPreviousUrl(url: string) { + this.previousUrl = url; + } }