X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2F%2Bmy-account%2Fmy-account-notifications%2Fmy-account-notifications.component.ts;h=0ec67d4016bd0c0c3019e82aa0486b2119f5a37d;hb=4f5d045960b042eb27e10bac1bdaf1c074c9fa2a;hp=8a51319fe5bc752769fcf31535856e77965f067d;hpb=bc99dfe54e093e69ba8fd06d36b36fbbda3f45de;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/+my-account/my-account-notifications/my-account-notifications.component.ts b/client/src/app/+my-account/my-account-notifications/my-account-notifications.component.ts index 8a51319fe..0ec67d401 100644 --- a/client/src/app/+my-account/my-account-notifications/my-account-notifications.component.ts +++ b/client/src/app/+my-account/my-account-notifications/my-account-notifications.component.ts @@ -1,6 +1,8 @@ import { Component, ViewChild } from '@angular/core' import { UserNotificationsComponent } from '@app/shared/shared-main' +type NotificationSortType = 'createdAt' | 'read' + @Component({ templateUrl: './my-account-notifications.component.html', styleUrls: [ './my-account-notifications.component.scss' ] @@ -8,7 +10,17 @@ import { UserNotificationsComponent } from '@app/shared/shared-main' export class MyAccountNotificationsComponent { @ViewChild('userNotification', { static: true }) userNotification: UserNotificationsComponent - notificationSortType = 'created' + _notificationSortType: NotificationSortType = 'createdAt' + + get notificationSortType () { + return !this.hasUnreadNotifications() + ? 'createdAt' + : this._notificationSortType + } + + set notificationSortType (type: NotificationSortType) { + this._notificationSortType = type + } markAllAsRead () { this.userNotification.markAllAsRead() @@ -17,4 +29,8 @@ export class MyAccountNotificationsComponent { hasUnreadNotifications () { return this.userNotification.notifications.filter(n => n.read === false).length !== 0 } + + onChangeSortColumn () { + this.userNotification.changeSortColumn(this.notificationSortType) + } }