]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/users/user-notifications.component.ts
Changelog typos
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / users / user-notifications.component.ts
index ce43b604a33a929abd25447310a5e2fb01f7efd3..977dd8925c80eea6db5703f7eb7f21d00f41ef7c 100644 (file)
@@ -4,6 +4,7 @@ import { UserNotificationType } from '../../../../../shared'
 import { ComponentPagination, hasMoreItems } from '@app/shared/rest/component-pagination.model'
 import { Notifier } from '@app/core'
 import { UserNotification } from '@app/shared/users/user-notification.model'
+import { Subject } from 'rxjs'
 
 @Component({
   selector: 'my-user-notifications',
@@ -14,6 +15,7 @@ export class UserNotificationsComponent implements OnInit {
   @Input() ignoreLoadingBar = false
   @Input() infiniteScroll = true
   @Input() itemsPerPage = 20
+  @Input() markAllAsReadSubject: Subject<boolean>
 
   @Output() notificationsLoaded = new EventEmitter()
 
@@ -24,6 +26,8 @@ export class UserNotificationsComponent implements OnInit {
 
   componentPagination: ComponentPagination
 
+  onDataSubject = new Subject<any[]>()
+
   constructor (
     private userNotificationService: UserNotificationService,
     private notifier: Notifier
@@ -37,6 +41,10 @@ export class UserNotificationsComponent implements OnInit {
     }
 
     this.loadMoreNotifications()
+
+    if (this.markAllAsReadSubject) {
+      this.markAllAsReadSubject.subscribe(() => this.markAllAsRead())
+    }
   }
 
   loadMoreNotifications () {
@@ -47,6 +55,8 @@ export class UserNotificationsComponent implements OnInit {
             this.componentPagination.totalItems = result.total
 
             this.notificationsLoaded.emit()
+
+            this.onDataSubject.next(result.data)
           },
 
           err => this.notifier.error(err.message)