Skip to content

Commit 703183a

Browse files
authored
Merge pull request trungvose#51 from trungk18/phase1-bugs-fixing
trungvose#49 - Use the setLoading operator, change map to tap
2 parents 17b3618 + 00bc528 commit 703183a

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

frontend/src/app/project/state/project/project.service.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { HttpClient } from '@angular/common/http';
22
import { Injectable } from '@angular/core';
3-
import { arrayRemove, arrayUpsert } from '@datorama/akita';
3+
import { arrayRemove, arrayUpsert, setLoading } from '@datorama/akita';
44
import { JComment } from '@trungk18/interface/comment';
55
import { JIssue } from '@trungk18/interface/issue';
66
import { 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';
910
import { environment } from 'src/environments/environment';
1011
import { 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

Comments
 (0)