]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+my-account/my-account-notifications/my-account-notifications.component.ts
Fix confirm modal containing 2 inputs
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account-notifications / my-account-notifications.component.ts
index a50cb0fb94f60d7b6c819163fadaa7f5334cc519..0ec67d4016bd0c0c3019e82aa0486b2119f5a37d 100644 (file)
@@ -1,5 +1,7 @@
 import { Component, ViewChild } from '@angular/core'
-import { UserNotificationsComponent } from '@app/shared'
+import { UserNotificationsComponent } from '@app/shared/shared-main'
+
+type NotificationSortType = 'createdAt' | 'read'
 
 @Component({
   templateUrl: './my-account-notifications.component.html',
@@ -8,6 +10,18 @@ import { UserNotificationsComponent } from '@app/shared'
 export class MyAccountNotificationsComponent {
   @ViewChild('userNotification', { static: true }) userNotification: UserNotificationsComponent
 
+  _notificationSortType: NotificationSortType = 'createdAt'
+
+  get notificationSortType () {
+    return !this.hasUnreadNotifications()
+      ? 'createdAt'
+      : this._notificationSortType
+  }
+
+  set notificationSortType (type: NotificationSortType) {
+    this._notificationSortType = type
+  }
+
   markAllAsRead () {
     this.userNotification.markAllAsRead()
   }
@@ -15,4 +29,8 @@ export class MyAccountNotificationsComponent {
   hasUnreadNotifications () {
     return this.userNotification.notifications.filter(n => n.read === false).length !== 0
   }
+
+  onChangeSortColumn () {
+    this.userNotification.changeSortColumn(this.notificationSortType)
+  }
 }