import { Subject } from 'rxjs'
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
import { ComponentPagination, hasMoreItems, Notifier } from '@app/core'
-import { UserNotificationType } from '@shared/models'
+import { UserNotificationType, AbuseState } from '@shared/models'
import { UserNotification } from './user-notification.model'
import { UserNotificationService } from './user-notification.service'
notifications: UserNotification[] = []
sortField = 'createdAt'
- // So we can access it in the template
- UserNotificationType = UserNotificationType
-
componentPagination: ComponentPagination
onDataSubject = new Subject<any[]>()
}
loadNotifications (reset?: boolean) {
- this.userNotificationService.listMyNotifications({
+ const options = {
pagination: this.componentPagination,
ignoreLoadingBar: this.ignoreLoadingBar,
sort: {
// if we order by creation date, we want DESC. all other fields are ASC (like unread).
order: this.sortField === 'createdAt' ? -1 : 1
}
- })
+ }
+
+ this.userNotificationService.listMyNotifications(options)
.subscribe(
result => {
this.notifications = reset ? result.data : this.notifications.concat(result.data)
this.sortField = column
this.loadNotifications(true)
}
+
+ isAccepted (notification: UserNotification) {
+ return notification.abuse.state === AbuseState.ACCEPTED
+ }
}