Add retry handler to all BaseService extending services

master
trivernis 5 years ago
parent 98a58c697d
commit 31e915d074

@ -77,7 +77,9 @@ export class ProfileService extends BaseService {
public getUserData(userId: string) { public getUserData(userId: string) {
const headers = new Headers(); const headers = new Headers();
headers.set('Content-Type', 'application/json'); headers.set('Content-Type', 'application/json');
this.http.post(environment.graphQLUrl, ProfileService.buildGetProfileBody(userId)).subscribe(result => { this.http.post(environment.graphQLUrl, ProfileService.buildGetProfileBody(userId))
.pipe(this.retryRated())
.subscribe(result => {
this.proflile.next(this.getProfileData(result)); this.proflile.next(this.getProfileData(result));
return this.proflile; return this.proflile;
}); });

@ -101,6 +101,7 @@ export class SearchService extends BaseService {
*/ */
public search(query: string): Observable<ISearchRequestResult> { public search(query: string): Observable<ISearchRequestResult> {
const body = SearchService.buildRequestBody(query); const body = SearchService.buildRequestBody(query);
return this.http.post<ISearchRequestResult>(environment.graphQLUrl, body, {headers: this.headers}); return this.http.post<ISearchRequestResult>(environment.graphQLUrl, body, {headers: this.headers})
.pipe(this.retryRated());
} }
} }

@ -62,6 +62,7 @@ export class SelfService extends BaseService {
headers.set('Content-Type', 'application/json'); headers.set('Content-Type', 'application/json');
return this.http.post(url, SelfService.buildGetSelfBody(), {headers: this.headers}) return this.http.post(url, SelfService.buildGetSelfBody(), {headers: this.headers})
.pipe(this.retryRated())
.pipe(tap(response => { .pipe(tap(response => {
this.updateUserInfo(response); this.updateUserInfo(response);
})); }));
@ -74,7 +75,8 @@ export class SelfService extends BaseService {
public changeProfilePicture(file: any) { public changeProfilePicture(file: any) {
const formData: any = new FormData(); const formData: any = new FormData();
formData.append('profilePicture', file); formData.append('profilePicture', file);
return this.http.post<IFileUploadResult>(environment.greenvironmentUrl + '/upload', formData); return this.http.post<IFileUploadResult>(environment.greenvironmentUrl + '/upload', formData)
.pipe(this.retryRated());
} }
/** /**

@ -36,6 +36,7 @@ export class SocialService extends BaseService {
*/ */
createGroup(name: string) { createGroup(name: string) {
const body = SocialService.buildGroupCreateBody(name); const body = SocialService.buildGroupCreateBody(name);
return this.http.post(environment.graphQLUrl, body, {headers: this.headers}); return this.http.post(environment.graphQLUrl, body, {headers: this.headers})
.pipe(this.retryRated());
} }
} }

Loading…
Cancel
Save