aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-main/users/user-notification.service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/shared-main/users/user-notification.service.ts')
-rw-r--r--client/src/app/shared/shared-main/users/user-notification.service.ts17
1 files changed, 10 insertions, 7 deletions
diff --git a/client/src/app/shared/shared-main/users/user-notification.service.ts b/client/src/app/shared/shared-main/users/user-notification.service.ts
index e27dab21a..e90bb0f1f 100644
--- a/client/src/app/shared/shared-main/users/user-notification.service.ts
+++ b/client/src/app/shared/shared-main/users/user-notification.service.ts
@@ -1,8 +1,9 @@
1import { SortMeta } from 'primeng/api' 1import { SortMeta } from 'primeng/api'
2import { catchError, map, tap } from 'rxjs/operators' 2import { catchError, map, tap } from 'rxjs/operators'
3import { HttpClient, HttpParams } from '@angular/common/http' 3import { HttpClient, HttpContext, HttpParams } from '@angular/common/http'
4import { Injectable } from '@angular/core' 4import { Injectable } from '@angular/core'
5import { AuthService, ComponentPaginationLight, PeerTubeSocket, RestExtractor, RestService } from '@app/core' 5import { AuthService, ComponentPaginationLight, PeerTubeSocket, RestExtractor, RestService } from '@app/core'
6import { NGX_LOADING_BAR_IGNORED } from '@ngx-loading-bar/http-client'
6import { ResultList, UserNotification as UserNotificationServer, UserNotificationSetting } from '@shared/models' 7import { ResultList, UserNotification as UserNotificationServer, UserNotificationSetting } from '@shared/models'
7import { environment } from '../../../../environments/environment' 8import { environment } from '../../../../environments/environment'
8import { UserNotification } from './user-notification.model' 9import { UserNotification } from './user-notification.model'
@@ -33,9 +34,11 @@ export class UserNotificationService {
33 34
34 if (unread) params = params.append('unread', `${unread}`) 35 if (unread) params = params.append('unread', `${unread}`)
35 36
36 const headers = ignoreLoadingBar ? { ignoreLoadingBar: '' } : undefined 37 const context = ignoreLoadingBar
38 ? new HttpContext().set(NGX_LOADING_BAR_IGNORED, true)
39 : undefined
37 40
38 return this.authHttp.get<ResultList<UserNotification>>(UserNotificationService.BASE_NOTIFICATIONS_URL, { params, headers }) 41 return this.authHttp.get<ResultList<UserNotification>>(UserNotificationService.BASE_NOTIFICATIONS_URL, { params, context })
39 .pipe( 42 .pipe(
40 map(res => this.restExtractor.convertResultListDateToHuman(res)), 43 map(res => this.restExtractor.convertResultListDateToHuman(res)),
41 map(res => this.restExtractor.applyToResultListData(res, this.formatNotification.bind(this))), 44 map(res => this.restExtractor.applyToResultListData(res, this.formatNotification.bind(this))),
@@ -52,9 +55,9 @@ export class UserNotificationService {
52 const url = UserNotificationService.BASE_NOTIFICATIONS_URL + '/read' 55 const url = UserNotificationService.BASE_NOTIFICATIONS_URL + '/read'
53 56
54 const body = { ids: [ notification.id ] } 57 const body = { ids: [ notification.id ] }
55 const headers = { ignoreLoadingBar: '' } 58 const context = new HttpContext().set(NGX_LOADING_BAR_IGNORED, true)
56 59
57 return this.authHttp.post(url, body, { headers }) 60 return this.authHttp.post(url, body, { context })
58 .pipe( 61 .pipe(
59 map(this.restExtractor.extractDataBool), 62 map(this.restExtractor.extractDataBool),
60 tap(() => this.peertubeSocket.dispatchNotificationEvent('read')), 63 tap(() => this.peertubeSocket.dispatchNotificationEvent('read')),
@@ -64,9 +67,9 @@ export class UserNotificationService {
64 67
65 markAllAsRead () { 68 markAllAsRead () {
66 const url = UserNotificationService.BASE_NOTIFICATIONS_URL + '/read-all' 69 const url = UserNotificationService.BASE_NOTIFICATIONS_URL + '/read-all'
67 const headers = { ignoreLoadingBar: '' } 70 const context = new HttpContext().set(NGX_LOADING_BAR_IGNORED, true)
68 71
69 return this.authHttp.post(url, {}, { headers }) 72 return this.authHttp.post(url, {}, { context })
70 .pipe( 73 .pipe(
71 map(this.restExtractor.extractDataBool), 74 map(this.restExtractor.extractDataBool),
72 tap(() => this.peertubeSocket.dispatchNotificationEvent('read-all')), 75 tap(() => this.peertubeSocket.dispatchNotificationEvent('read-all')),