]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+my-account/my-account-notifications/my-account-notifications.component.ts
Clearer video creation from API regarding rates
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account-notifications / my-account-notifications.component.ts
1 import { Component, ViewChild } from '@angular/core'
2 import { UserNotificationsComponent } from '@app/shared/shared-main'
3
4 type NotificationSortType = 'createdAt' | 'read'
5
6 @Component({
7 templateUrl: './my-account-notifications.component.html',
8 styleUrls: [ './my-account-notifications.component.scss' ]
9 })
10 export class MyAccountNotificationsComponent {
11 @ViewChild('userNotification', { static: true }) userNotification: UserNotificationsComponent
12
13 _notificationSortType: NotificationSortType = 'createdAt'
14
15 get notificationSortType () {
16 return !this.hasUnreadNotifications()
17 ? 'createdAt'
18 : this._notificationSortType
19 }
20
21 set notificationSortType (type: NotificationSortType) {
22 this._notificationSortType = type
23 }
24
25 markAllAsRead () {
26 this.userNotification.markAllAsRead()
27 }
28
29 hasUnreadNotifications () {
30 return this.userNotification.notifications.filter(n => n.read === false).length !== 0
31 }
32
33 onChangeSortColumn () {
34 this.userNotification.changeSortColumn(this.notificationSortType)
35 }
36 }