X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fusers%2Fuser-notifications.component.ts;h=977dd8925c80eea6db5703f7eb7f21d00f41ef7c;hb=366b21f13f75b33f9d64744d7564e7cddf5b1ae8;hp=b5f9fd3991ab81fa254b129426b63b6c585d1669;hpb=73471b1a52f242e86364ffb077ea6cadb3b07ae2;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/users/user-notifications.component.ts b/client/src/app/shared/users/user-notifications.component.ts index b5f9fd399..977dd8925 100644 --- a/client/src/app/shared/users/user-notifications.component.ts +++ b/client/src/app/shared/users/user-notifications.component.ts @@ -1,9 +1,10 @@ -import { Component, Input, OnInit } from '@angular/core' +import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' import { UserNotificationService } from '@app/shared/users/user-notification.service' 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,9 @@ export class UserNotificationsComponent implements OnInit { @Input() ignoreLoadingBar = false @Input() infiniteScroll = true @Input() itemsPerPage = 20 + @Input() markAllAsReadSubject: Subject + + @Output() notificationsLoaded = new EventEmitter() notifications: UserNotification[] = [] @@ -22,6 +26,8 @@ export class UserNotificationsComponent implements OnInit { componentPagination: ComponentPagination + onDataSubject = new Subject() + constructor ( private userNotificationService: UserNotificationService, private notifier: Notifier @@ -35,6 +41,10 @@ export class UserNotificationsComponent implements OnInit { } this.loadMoreNotifications() + + if (this.markAllAsReadSubject) { + this.markAllAsReadSubject.subscribe(() => this.markAllAsRead()) + } } loadMoreNotifications () { @@ -43,6 +53,10 @@ export class UserNotificationsComponent implements OnInit { result => { this.notifications = this.notifications.concat(result.data) this.componentPagination.totalItems = result.total + + this.notificationsLoaded.emit() + + this.onDataSubject.next(result.data) }, err => this.notifier.error(err.message)