diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-07-15 11:15:50 +0200 |
---|---|---|
committer | Rigel Kent <par@rigelk.eu> | 2020-07-29 18:15:53 +0200 |
commit | 654a188f80fc1f089aa14837084664c908fe27d2 (patch) | |
tree | 63855915278c1a3aeb1509c09a7a2f5ee6977893 /client/src/app/shared/shared-main/users/user-notification.service.ts | |
parent | 292c17b894e430d61f9197fb6fa245f5f9c6fa7c (diff) | |
download | PeerTube-654a188f80fc1f089aa14837084664c908fe27d2.tar.gz PeerTube-654a188f80fc1f089aa14837084664c908fe27d2.tar.zst PeerTube-654a188f80fc1f089aa14837084664c908fe27d2.zip |
allow sorting notifications
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.ts | 14 |
1 files changed, 11 insertions, 3 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 8dd9472fe..ecc66ecdb 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 | |||
@@ -5,6 +5,7 @@ import { ComponentPaginationLight, RestExtractor, RestService, User, UserNotific | |||
5 | import { ResultList, UserNotification as UserNotificationServer, UserNotificationSetting } from '@shared/models' | 5 | import { ResultList, UserNotification as UserNotificationServer, UserNotificationSetting } from '@shared/models' |
6 | import { environment } from '../../../../environments/environment' | 6 | import { environment } from '../../../../environments/environment' |
7 | import { UserNotification } from './user-notification.model' | 7 | import { UserNotification } from './user-notification.model' |
8 | import { SortMeta } from 'primeng/api' | ||
8 | 9 | ||
9 | @Injectable() | 10 | @Injectable() |
10 | export class UserNotificationService { | 11 | export class UserNotificationService { |
@@ -18,9 +19,16 @@ export class UserNotificationService { | |||
18 | private userNotificationSocket: UserNotificationSocket | 19 | private userNotificationSocket: UserNotificationSocket |
19 | ) {} | 20 | ) {} |
20 | 21 | ||
21 | listMyNotifications (pagination: ComponentPaginationLight, unread?: boolean, ignoreLoadingBar = false) { | 22 | listMyNotifications (parameters: { |
23 | pagination: ComponentPaginationLight | ||
24 | ignoreLoadingBar?: boolean | ||
25 | unread?: boolean, | ||
26 | sort?: SortMeta | ||
27 | }) { | ||
28 | const { pagination, ignoreLoadingBar, unread, sort } = parameters | ||
29 | |||
22 | let params = new HttpParams() | 30 | let params = new HttpParams() |
23 | params = this.restService.addRestGetParams(params, this.restService.componentPaginationToRestPagination(pagination)) | 31 | params = this.restService.addRestGetParams(params, this.restService.componentPaginationToRestPagination(pagination), sort) |
24 | 32 | ||
25 | if (unread) params = params.append('unread', `${unread}`) | 33 | if (unread) params = params.append('unread', `${unread}`) |
26 | 34 | ||
@@ -35,7 +43,7 @@ export class UserNotificationService { | |||
35 | } | 43 | } |
36 | 44 | ||
37 | countUnreadNotifications () { | 45 | countUnreadNotifications () { |
38 | return this.listMyNotifications({ currentPage: 1, itemsPerPage: 0 }, true) | 46 | return this.listMyNotifications({ pagination: { currentPage: 1, itemsPerPage: 0 }, ignoreLoadingBar: true, unread: true }) |
39 | .pipe(map(n => n.total)) | 47 | .pipe(map(n => n.total)) |
40 | } | 48 | } |
41 | 49 | ||