From 29716c4681f0e016e5f25291e95a143ade39faee Mon Sep 17 00:00:00 2001 From: crupest Date: Wed, 13 Mar 2019 22:04:09 +0800 Subject: Use route to control user dialog. --- .../app/user/user-dialog/user-dialog.component.ts | 23 +++------------------- 1 file changed, 3 insertions(+), 20 deletions(-) (limited to 'Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.ts') diff --git a/Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.ts b/Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.ts index cf5f3643..2887f0a6 100644 --- a/Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.ts +++ b/Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.ts @@ -1,5 +1,4 @@ -import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core'; -import { InternalUserService } from '../internal-user-service/internal-user.service'; +import { Component, OnInit, ViewChild } from '@angular/core'; import { RouterOutlet, Router, ActivationStart } from '@angular/router'; @Component({ @@ -7,14 +6,12 @@ import { RouterOutlet, Router, ActivationStart } from '@angular/router'; templateUrl: './user-dialog.component.html', styleUrls: ['./user-dialog.component.css'] }) -export class UserDialogComponent implements OnInit, OnDestroy { +export class UserDialogComponent implements OnInit { - constructor(private userService: InternalUserService, private router: Router) { } + constructor(private router: Router) { } @ViewChild(RouterOutlet) outlet!: RouterOutlet; - isLoading = true; - ngOnInit() { // this is a workaround for a bug. see https://github.com/angular/angular/issues/20694 const subscription = this.router.events.subscribe(e => { @@ -23,19 +20,5 @@ export class UserDialogComponent implements OnInit, OnDestroy { subscription.unsubscribe(); } }); - - - this.userService.refreshAndGetUserState().subscribe(result => { - this.isLoading = false; - if (result === 'success') { - this.userService.userRouteNavigate(['success', { reason: 'already' }]); - } else { - this.userService.userRouteNavigate(['login', { reason: result }]); - } - }); - } - - ngOnDestroy() { - this.userService.userRouteNavigate(null); } } -- cgit v1.2.3