11import  {  HttpClient  }  from  '@angular/common/http' ; 
22import  {  Injectable  }  from  '@angular/core' ; 
3- import  {  arrayRemove ,  arrayUpsert  }  from  '@datorama/akita' ; 
3+ import  {  arrayRemove ,  arrayUpsert ,   setLoading  }  from  '@datorama/akita' ; 
44import  {  JComment  }  from  '@trungk18/interface/comment' ; 
55import  {  JIssue  }  from  '@trungk18/interface/issue' ; 
66import  {  JProject  }  from  '@trungk18/interface/project' ; 
7- import  {  of ,  Subscription  }  from  'rxjs' ; 
8- import  {  catchError ,  finalize ,  map  }  from  'rxjs/operators' ; 
7+ import  {  DateUtil  }  from  '@trungk18/project/utils/date' ; 
8+ import  {  of  }  from  'rxjs' ; 
9+ import  {  catchError ,  tap  }  from  'rxjs/operators' ; 
910import  {  environment  }  from  'src/environments/environment' ; 
1011import  {  ProjectStore  }  from  './project.store' ; 
11- import  {  DateUtil  }  from  '@trungk18/project/utils/date' ; 
1212
1313@Injectable ( { 
1414  providedIn : 'root' 
@@ -25,21 +25,18 @@ export class ProjectService {
2525  } 
2626
2727  getProject ( )  { 
28-     this . setLoading ( true ) ; 
2928    this . _http 
3029      . get < JProject > ( `${ this . baseUrl }  /project` ) 
3130      . pipe ( 
32-         map ( ( project )  =>  { 
31+         setLoading ( this . _store ) , 
32+         tap ( ( project )  =>  { 
3333          this . _store . update ( ( state )  =>  { 
3434            return  { 
3535              ...state , 
3636              ...project 
3737            } ; 
3838          } ) ; 
3939        } ) , 
40-         finalize ( ( )  =>  { 
41-           this . setLoading ( false ) ; 
42-         } ) , 
4340        catchError ( ( error )  =>  { 
4441          this . _store . setError ( error ) ; 
4542          return  of ( error ) ; 
0 commit comments