]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+my-account/my-account-notifications/my-account-notifications.component.ts
harmonize search for libraries
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account-notifications / my-account-notifications.component.ts
CommitLineData
2f1548fd 1import { Component, ViewChild } from '@angular/core'
67ed6552 2import { UserNotificationsComponent } from '@app/shared/shared-main'
2f1548fd 3
4f5d0459
RK
4type NotificationSortType = 'createdAt' | 'read'
5
2f1548fd
C
6@Component({
7 templateUrl: './my-account-notifications.component.html',
8 styleUrls: [ './my-account-notifications.component.scss' ]
9})
10export class MyAccountNotificationsComponent {
f36da21e 11 @ViewChild('userNotification', { static: true }) userNotification: UserNotificationsComponent
2f1548fd 12
4f5d0459
RK
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 }
654a188f 24
2f1548fd
C
25 markAllAsRead () {
26 this.userNotification.markAllAsRead()
27 }
10475dea 28
bc6f8863
C
29 hasUnreadNotifications () {
30 return this.userNotification.notifications.filter(n => n.read === false).length !== 0
10475dea 31 }
4f5d0459
RK
32
33 onChangeSortColumn () {
34 this.userNotification.changeSortColumn(this.notificationSortType)
35 }
2f1548fd 36}