From 9744bb2ae8284c4589b66055c1d99997abf18748 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 29 Dec 2021 11:46:26 +0100 Subject: Fix ngx loading bar deprecation --- .../shared-main/users/user-notification.service.ts | 17 ++++++++++------- .../shared-video-playlist/video-playlist.service.ts | 5 +++-- 2 files changed, 13 insertions(+), 9 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 @@ import { SortMeta } from 'primeng/api' import { catchError, map, tap } from 'rxjs/operators' -import { HttpClient, HttpParams } from '@angular/common/http' +import { HttpClient, HttpContext, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' import { AuthService, ComponentPaginationLight, PeerTubeSocket, RestExtractor, RestService } from '@app/core' +import { NGX_LOADING_BAR_IGNORED } from '@ngx-loading-bar/http-client' import { ResultList, UserNotification as UserNotificationServer, UserNotificationSetting } from '@shared/models' import { environment } from '../../../../environments/environment' import { UserNotification } from './user-notification.model' @@ -33,9 +34,11 @@ export class UserNotificationService { if (unread) params = params.append('unread', `${unread}`) - const headers = ignoreLoadingBar ? { ignoreLoadingBar: '' } : undefined + const context = ignoreLoadingBar + ? new HttpContext().set(NGX_LOADING_BAR_IGNORED, true) + : undefined - return this.authHttp.get>(UserNotificationService.BASE_NOTIFICATIONS_URL, { params, headers }) + return this.authHttp.get>(UserNotificationService.BASE_NOTIFICATIONS_URL, { params, context }) .pipe( map(res => this.restExtractor.convertResultListDateToHuman(res)), map(res => this.restExtractor.applyToResultListData(res, this.formatNotification.bind(this))), @@ -52,9 +55,9 @@ export class UserNotificationService { const url = UserNotificationService.BASE_NOTIFICATIONS_URL + '/read' const body = { ids: [ notification.id ] } - const headers = { ignoreLoadingBar: '' } + const context = new HttpContext().set(NGX_LOADING_BAR_IGNORED, true) - return this.authHttp.post(url, body, { headers }) + return this.authHttp.post(url, body, { context }) .pipe( map(this.restExtractor.extractDataBool), tap(() => this.peertubeSocket.dispatchNotificationEvent('read')), @@ -64,9 +67,9 @@ export class UserNotificationService { markAllAsRead () { const url = UserNotificationService.BASE_NOTIFICATIONS_URL + '/read-all' - const headers = { ignoreLoadingBar: '' } + const context = new HttpContext().set(NGX_LOADING_BAR_IGNORED, true) - return this.authHttp.post(url, {}, { headers }) + return this.authHttp.post(url, {}, { context }) .pipe( map(this.restExtractor.extractDataBool), tap(() => this.peertubeSocket.dispatchNotificationEvent('read-all')), diff --git a/client/src/app/shared/shared-video-playlist/video-playlist.service.ts b/client/src/app/shared/shared-video-playlist/video-playlist.service.ts index 3faf81d11..44d930b07 100644 --- a/client/src/app/shared/shared-video-playlist/video-playlist.service.ts +++ b/client/src/app/shared/shared-video-playlist/video-playlist.service.ts @@ -1,11 +1,12 @@ import * as debug from 'debug' import { merge, Observable, of, ReplaySubject, Subject } from 'rxjs' import { catchError, filter, map, share, switchMap, tap } from 'rxjs/operators' -import { HttpClient, HttpParams } from '@angular/common/http' +import { HttpClient, HttpContext, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' import { AuthUser, ComponentPaginationLight, RestExtractor, RestService, ServerService } from '@app/core' import { buildBulkObservable, objectToFormData } from '@app/helpers' import { Account, AccountService, VideoChannel, VideoChannelService } from '@app/shared/shared-main' +import { NGX_LOADING_BAR_IGNORED } from '@ngx-loading-bar/http-client' import { ResultList, VideoExistInPlaylist, @@ -350,7 +351,7 @@ export class VideoPlaylistService { let params = new HttpParams() params = this.restService.addObjectParams(params, { videoIds }) - return this.authHttp.get(url, { params, headers: { ignoreLoadingBar: '' } }) + return this.authHttp.get(url, { params, context: new HttpContext().set(NGX_LOADING_BAR_IGNORED, true) }) .pipe(catchError(err => this.restExtractor.handleError(err))) } } -- cgit v1.2.3