2015-07-15 12:30:11 +08:00
|
|
|
import Model from 'flarum/Model';
|
|
|
|
import mixin from 'flarum/utils/mixin';
|
2015-04-25 20:58:39 +08:00
|
|
|
import computed from 'flarum/utils/computed';
|
|
|
|
|
2015-07-15 12:30:11 +08:00
|
|
|
export default class Notification extends mixin(Model, {
|
|
|
|
contentType: Model.attribute('contentType'),
|
|
|
|
subjectId: Model.attribute('subjectId'),
|
|
|
|
content: Model.attribute('content'),
|
|
|
|
time: Model.attribute('time', Model.date),
|
2015-04-25 20:58:39 +08:00
|
|
|
|
2015-07-15 12:30:11 +08:00
|
|
|
isRead: Model.attribute('isRead'),
|
|
|
|
unreadCount: Model.attribute('unreadCount'),
|
|
|
|
additionalUnreadCount: computed('unreadCount', unreadCount => Math.max(0, unreadCount - 1)),
|
2015-04-25 20:58:39 +08:00
|
|
|
|
2015-07-15 12:30:11 +08:00
|
|
|
user: Model.hasOne('user'),
|
|
|
|
sender: Model.hasOne('sender'),
|
|
|
|
subject: Model.hasOne('subject')
|
|
|
|
}) {}
|