File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed
Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import { AuthService } from '../../services/auth-service'
1515import { Router } from '@angular/router'
1616import { takeUntilDestroyed } from '@angular/core/rxjs-interop'
1717import { MatProgressBar } from '@angular/material/progress-bar'
18+ import { catchError , of } from 'rxjs'
1819
1920@Component ( {
2021 selector : 'app-login-form' ,
@@ -63,12 +64,18 @@ export class LoginForm {
6364 this . isLoading . set ( true )
6465 this . authService
6566 . login ( this . formData ( ) )
66- . pipe ( takeUntilDestroyed ( this . destroyRef ) )
67+ . pipe (
68+ takeUntilDestroyed ( this . destroyRef ) ,
69+ catchError ( ( ) => {
70+ this . isLoading . set ( false )
71+ return of ( null )
72+ } ) ,
73+ )
6774 . subscribe ( ( result ) => {
6875 if ( result ) {
69- this . isLoading . set ( false )
7076 this . router . navigate ( [ '/articles' ] )
7177 }
78+ this . isLoading . set ( false )
7279 } )
7380 }
7481}
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import { takeUntilDestroyed } from '@angular/core/rxjs-interop'
1010import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'
1111import { MatIconModule } from '@angular/material/icon'
1212import { MatProgressBarModule } from '@angular/material/progress-bar'
13+ import { catchError , of } from 'rxjs'
1314
1415@Component ( {
1516 selector : 'app-signup-form' ,
@@ -51,12 +52,18 @@ export class SignupForm {
5152 this . isLoading . set ( true )
5253 this . authService
5354 . signup ( { password : this . password . value as string } )
54- . pipe ( takeUntilDestroyed ( this . destroyRef ) )
55+ . pipe (
56+ takeUntilDestroyed ( this . destroyRef ) ,
57+ catchError ( ( ) => {
58+ this . isLoading . set ( false )
59+ return of ( null )
60+ } ) ,
61+ )
5562 . subscribe ( ( result ) => {
5663 if ( result ) {
57- this . isLoading . set ( false )
5864 this . router . navigate ( [ '/user' ] )
5965 }
66+ this . isLoading . set ( false )
6067 } )
6168 }
6269}
You can’t perform that action at this time.
0 commit comments